T --> _ in Z
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Tue, 14 Oct 2025 05:37:08 +0000 (05:37 +0000)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Tue, 14 Oct 2025 05:37:08 +0000 (05:37 +0000)
developer/C/noop.lib.c [new file with mode: 0644]
developer/tool/makefile [new file with mode: 0644]
env_developer
tool_shared/bespoke/env
tool_shared/customized/.githolder [deleted file]
tool_shared/document/install_generic.org [new file with mode: 0644]
tool_shared/patch/.githolder [new file with mode: 0644]
tool_shared/patch/RT_gcc [new file with mode: 0644]
tool_shared/third_party/.gitignore

diff --git a/developer/C/noop.lib.c b/developer/C/noop.lib.c
new file mode 100644 (file)
index 0000000..f6c5586
--- /dev/null
@@ -0,0 +1,69 @@
+// rabit_noop.c β€” Rabit no-op netfilter interposer (Debian 12/Bookworm)
+// Build: out-of-tree module. Load/unload to verify hook coverage.
+// Behavior: increments counters, returns NF_ACCEPT. No packet mutation.
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/version.h>
+#include <linux/skbuff.h>
+#include <linux/atomic.h>
+#include <linux/netdevice.h>
+#include <linux/netfilter.h>
+#include <linux/netfilter_ipv4.h>
+#include <linux/netfilter_ipv6.h>
+
+static atomic64_t cnt_v4_local_out  = ATOMIC_LONG_INIT(0);
+static atomic64_t cnt_v4_postroute  = ATOMIC_LONG_INIT(0);
+static atomic64_t cnt_v6_local_out  = ATOMIC_LONG_INIT(0);
+static atomic64_t cnt_v6_postroute  = ATOMIC_LONG_INIT(0);
+
+static unsigned int rabit_v4_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *st) {
+  if (st->hook == NF_INET_LOCAL_OUT)     atomic64_inc(&cnt_v4_local_out);
+  else if (st->hook == NF_INET_POST_ROUTING) atomic64_inc(&cnt_v4_postroute);
+  return NF_ACCEPT;
+}
+
+static unsigned int rabit_v6_hook(void *priv, struct sk_buff *skb, const struct nf_hook_state *st) {
+  if (st->hook == NF_INET_LOCAL_OUT)     atomic64_inc(&cnt_v6_local_out);
+  else if (st->hook == NF_INET_POST_ROUTING) atomic64_inc(&cnt_v6_postroute);
+  return NF_ACCEPT;
+}
+
+static struct nf_hook_ops rabit_ops[] = {
+  { .hook = rabit_v4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_LOCAL_OUT,   .priority = NF_IP_PRI_FIRST },
+  { .hook = rabit_v4_hook, .pf = NFPROTO_IPV4, .hooknum = NF_INET_POST_ROUTING,.priority = NF_IP_PRI_FIRST },
+  { .hook = rabit_v6_hook, .pf = NFPROTO_IPV6, .hooknum = NF_INET_LOCAL_OUT,   .priority = NF_IP6_PRI_FIRST },
+  { .hook = rabit_v6_hook, .pf = NFPROTO_IPV6, .hooknum = NF_INET_POST_ROUTING,.priority = NF_IP6_PRI_FIRST },
+};
+
+static int __init rabit_init(void) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)
+  int ret = nf_register_net_hooks(&init_net, rabit_ops, ARRAY_SIZE(rabit_ops));
+#else
+  int ret = nf_register_hooks(rabit_ops, ARRAY_SIZE(rabit_ops));
+#endif
+  if (ret)
+    pr_err("rabit_noop: nf_register_* failed: %d\n", ret);
+  else
+    pr_info("rabit_noop: loaded (no-op)\n");
+  return ret;
+}
+
+static void __exit rabit_exit(void) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,3,0)
+  nf_unregister_net_hooks(&init_net, rabit_ops, ARRAY_SIZE(rabit_ops));
+#else
+  nf_unregister_hooks(rabit_ops, ARRAY_SIZE(rabit_ops));
+#endif
+  pr_info("rabit_noop: unload stats v4(lo=%lld,po=%lld) v6(lo=%lld,po=%lld)\n",
+          (long long)atomic64_read(&cnt_v4_local_out),
+          (long long)atomic64_read(&cnt_v4_postroute),
+          (long long)atomic64_read(&cnt_v6_local_out),
+          (long long)atomic64_read(&cnt_v6_postroute));
+}
+
+module_init(rabit_init);
+module_exit(rabit_exit);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Rabit");
+MODULE_DESCRIPTION("Rabit no-op netfilter interposer");
diff --git a/developer/tool/makefile b/developer/tool/makefile
new file mode 100644 (file)
index 0000000..42ab937
--- /dev/null
@@ -0,0 +1,17 @@
+
+RT-INCOMMON:=$(REPO_HOME)/tool_shared/third_party/RT-project-share/release
+
+include $(RT-INCOMMON)/make/environment_RT_0
+
+# To compile the example directory uncomment the following assignments:
+SRCDIR_List=example
+CFLAGS+=-IccπŸ–‰
+
+
+CFLAGS+= -include "$(RT-INCOMMON)/make/RT_0.h"
+LINKFLAGS+= -l$(PROJECT)
+LIBFILE=$(LIBDIR)/lib$(PROJECT).a
+
+include $(RT-INCOMMON)/make/targets_developer
+-include $(DEPFILE)
+
index 24f92fe..8ee077f 100644 (file)
@@ -5,13 +5,37 @@ if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
   exit 1
 fi
 
-export ROLE=developer
+# project environment is ROLE agnostic
 source tool_shared/bespoke/env
+export ROLE=developer
 
+# setup tools
+
+export PYTHON_HOME="$REPO_HOME/tool_shared/third_party/python"
 if [[ ":$PATH:" != *":$PYTHON_HOME/bin:"* ]]; then
   export PATH="$PYTHON_HOME/bin:$PATH"
 fi
 
-cd $ROLE
+RT_gcc="$REPO_HOME/tool_shared/third_party/RT_gcc/release"
+if [[ ":$PATH:" != *":$RT_gcc:"* ]]; then
+  export PATH="$RT_gcc:$PATH"
+fi
+
+# include the developer/tool directory and env
+
+dev_tool=$REPO_HOME/developer/tool
+if [[ ":$PATH:" != *":$dev_tool:"* ]]; then
+  export PATH="$dev_tool:$PATH"
+fi
+
+if [[ -f "$ROLE/tool/env" ]]; then
+  source "$ROLE/tool/env"
+else
+  cd "$ROLE"
+fi
+
 export ENV=$ROLE
 echo "in environmennt: $ENV"
+
+
+
index eb93ff3..0d47fca 100644 (file)
@@ -8,6 +8,9 @@ fi
 # without this bash takes non-matching globs literally
 shopt -s nullglob
 
+# does not presume sharing or world permissions
+umask 0077
+
 # --------------------------------------------------------------------------------
 # project definition
 
diff --git a/tool_shared/customized/.githolder b/tool_shared/customized/.githolder
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/tool_shared/document/install_generic.org b/tool_shared/document/install_generic.org
new file mode 100644 (file)
index 0000000..919a354
--- /dev/null
@@ -0,0 +1,83 @@
+
+This is the generic install.org doc that comes with the skeleton.
+
+1. $REPO_HOME/tool_shared/third_party/.gitignore:
+
+    * 
+    !/.gitignore
+    !/patch
+
+  The only things from the third party directory that will be pushed to the repo origin is the .gitignore file and the patches.
+
+
+2. downloaded tar files etc. go into the directory `upstream`
+
+    $REPO_HOME/tool_shared/upstream
+   Typically the contents of upstream are deleted after the install.
+
+3. for the base install
+
+     cd $REPO_HOME/tool_shared/third_party
+     do whatever it takes to install tool, as examples:
+       git clone <tool_path>
+       tar -xzf ../upstream/tar
+       ...
+
+   Be sure to add the path to the tool executable(s) in the $REPO_HOME/env_$ROLE files for the $ROLE who uses the tool.
+
+   Assuming you are not also developing the tool, for safety
+   change each installed git project to a local branch:
+
+     b=<site>_<project>_local_$USER
+     git switch -c "$b"
+   
+
+4. Define some variables to simplify our discussion. Lowercase variable names
+   are not exported from the shell.
+
+     # already set in the environment
+     #   REPO_HOME
+     #   PROJECT
+     #   USER
+
+    # example tool names: 'RT_gcc' 'RT-project share`  etc.
+     tool=<tool-name>  
+     tool_dpath="$REPO_HOME/tool_shared/third_party/$tool"
+     patch_dpath="$REPO_HOME/tool_shared/patch/"
+
+
+5. create a patch series (from current vendor state β†’ your local edits)
+
+   # this can be repeated and will create an encompassing diff file
+
+   # optionally crate a new branch after cloning the third party tool repo and work from there.  You won't make any commits, but in case you plan to ever check the changes in, or have a the bad habit of doing ommits burned into your brain-stem, making a brnch will help.
+
+   # make changes
+
+     cd "$tool_dpath"
+
+     # do your edits
+
+     # Stage edits. Do not commit them!!  Be sure you are in the third party
+     # tool directory when doing `git add -A` and `git diff` commands.
+     git add -A
+
+     # diff the stage from the current repo to create the patch file
+     git diff --staged > "$patch_dpath/$tool"
+
+     # the diff file can be added to the project and checked in at the project level.
+
+
+6. how to apply an existing patch
+
+   Get a fresh clone of the tool into $tool_dpath.
+
+     cd "$tool_dpath"
+     git apply "$patch_dpath/$tool"
+
+   You can see what `git apply` would do by running 
+
+     git apply --check /path/to/your/patch_dpath/$tool
+
+   
diff --git a/tool_shared/patch/.githolder b/tool_shared/patch/.githolder
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tool_shared/patch/RT_gcc b/tool_shared/patch/RT_gcc
new file mode 100644 (file)
index 0000000..d15bae8
--- /dev/null
@@ -0,0 +1,8 @@
+diff --git a/release/gcc b/release/gcc
+new file mode 120000
+index 0000000..530a522
+--- /dev/null
++++ b/release/gcc
+@@ -0,0 +1 @@
++amd64_Deb-12.10_gcc-12.4.1/
+\ No newline at end of file
index 0de97f0..d83a92c 100644 (file)
@@ -4,5 +4,6 @@
 # But don't ignore the .gitignore file itself
 !/.gitignore
 
-# keep the upstream directory
-!/upstream
+# But don't ignore the patch files
+!/patch
+