@@ -7,23 +7,35 @@ IO boards, with HostMot2 firmware.
77
88== SYNOPSIS
99
10- *loadrt hm2_eth* [**config=**"__str__[,__str__...]"] [**board_ip=**__ip__[,__ip__...] ] [**board_mac=**__mac__[,__mac__...] ] [**no_iptables =**__0|1__ ]
10+ *loadrt hm2_eth* [**config=**"__str__[,__str__...]"] [**board_ip=**__ip__[,__ip__...] ] [**board_mac=**__mac__[,__mac__...] ] [**firewall =**__auto|iptables|nft|none__ ]
1111
1212*config* [default: ""]::
1313 HostMot2 config strings, described in the hostmot2(9) manpage.
1414*board_ip* [default: ""]::
1515 The IP address of the board(s), separated by commas.
1616 As shipped, the board address is 192.168.1.121.
17- *no_iptables* [default: 0]::
18- Explicit override that disables all iptables interaction. By default
19- hm2_eth installs *iptables* and *ip6tables* rules itself; rtapi_app
20- raises *cap_net_admin* into its ambient capability set at startup so
21- the calls succeed under both setuid-root and rootless (file-cap)
22- installs. If the cap is not held the probe fails and rule
23- installation is skipped with a warning; in that case configure the
24- rules manually using the recipe in the NOTES section below. Set
25- *no_iptables=1* when iptables is reachable but you prefer to manage
26- the firewall externally (nftables, firewalld, systemd units).
17+ *firewall* [default: auto]::
18+ Selects the firewall backend used to isolate the dedicated interface.
19+ By default hm2_eth installs the rules itself; rtapi_app raises
20+ *cap_net_admin* into its ambient capability set at startup so the
21+ calls succeed under both setuid-root and rootless (file-cap) installs.
22+ If the cap is not held (or no backend binary is present) the probe
23+ fails and rule installation is skipped with a warning; in that case
24+ configure the rules manually using the recipe in the NOTES section
25+ below. Accepted values:
26+ +
27+ --
28+ *auto*::: Use *iptables* when it is usable, otherwise fall back to
29+ *nft*. This preserves historical behaviour on iptables systems and
30+ works out of the box on nftables-only systems that have no iptables
31+ binary.
32+ *iptables*::: Force the legacy *iptables* / *ip6tables* backend.
33+ *nft*::: Force the *nftables* backend. Rules live in a dedicated
34+ *inet* table named *hm2_eth*, so flushing or removing them never
35+ touches your other firewall rules.
36+ *none*::: Disable all firewall interaction; manage the firewall
37+ externally (firewalld, systemd units, your own ruleset).
38+ --
2739
2840== DESCRIPTION
2941
@@ -140,19 +152,28 @@ Setting it too high can cause realtime delay errors.
140152
141153== NOTES
142154
143- hm2_eth uses an iptables chain called "hm2-eth-rules-output".
144- That technology is common to control network access to (INPUT chain),
145- through (FORWARD chain) or from (OUTPUT chain) your computer.
146- Someone who has configured a firewall on Linux has encountered iptables is familiar with that technology.
147- This chain contains additional rules to control network interface while HAL is running.
148- The chain is created if it does not exist,
149- and a jump to it is inserted at the beginning of the OUTPUT chain if it is not there already.
150- If you have an existing iptables setup,
151- you can insert a direct jump from OUTPUT to hm2-eth-rules-output in an order appropriate to your local network.
155+ hm2_eth installs firewall rules to control the network interface while
156+ HAL is running. Two backends are supported and chosen with the
157+ *firewall* parameter (see above): legacy *iptables* and *nftables*.
158+
159+ With the iptables backend, hm2_eth uses a chain called
160+ "hm2-eth-rules-output". That technology is common to control network
161+ access to (INPUT chain), through (FORWARD chain) or from (OUTPUT chain)
162+ your computer. The chain is created if it does not exist, and a jump to
163+ it is inserted at the beginning of the OUTPUT chain if it is not there
164+ already. If you have an existing iptables setup, you can insert a
165+ direct jump from OUTPUT to hm2-eth-rules-output in an order appropriate
166+ to your local network.
167+
168+ With the nftables backend, hm2_eth uses a dedicated *inet* table named
169+ "hm2_eth" with an *output*-hook chain. Because the table is private,
170+ flushing or deleting it never affects your other nftables rules.
152171
153172At (normal) exit, hm2_eth will remove the rules. After a crash, you can
154- manually clear the rules with *sudo iptables -F hm2-eth-rules-output*;
155- the rules are also removed by a reboot.
173+ manually clear the iptables rules with
174+ *sudo iptables -F hm2-eth-rules-output* (or, for nftables, with
175+ *sudo nft delete table inet hm2_eth*); the rules are also removed by a
176+ reboot.
156177
157178=== Manual iptables configuration
158179
@@ -201,6 +222,35 @@ ip6tables -D OUTPUT -j hm2-eth-rules-output
201222ip6tables -X hm2-eth-rules-output
202223----
203224
225+ === Manual nftables configuration
226+
227+ On nftables-only systems (no iptables binary), set the rules up as root
228+ with *nft*. The *inet* family covers IPv4 and IPv6 in one chain.
229+ Adjust the addresses, UDP destination port, and interface name:
230+
231+ ----
232+ HOST_IP=192.168.1.1
233+ BOARD_IP=192.168.1.121
234+ BOARD_DPORT=27181
235+ IFACE=eth1
236+
237+ nft add table inet hm2_eth
238+ nft add chain inet hm2_eth output \
239+ '{ type filter hook output priority 0; policy accept; }'
240+ nft add rule inet hm2_eth output \
241+ ip saddr $HOST_IP ip daddr $BOARD_IP udp dport $BOARD_DPORT accept
242+ nft add rule inet hm2_eth output oifname $IFACE ip protocol icmp drop
243+ nft add rule inet hm2_eth output oifname $IFACE \
244+ reject with icmp type admin-prohibited
245+ nft add rule inet hm2_eth output oifname $IFACE ip6 version 6 drop
246+ ----
247+
248+ Tear the rules down by deleting the whole private table:
249+
250+ ----
251+ nft delete table inet hm2_eth
252+ ----
253+
204254"hardware-irq-coalesce-rx-usecs" decreases time waiting to receive a packet on most systems,
205255but on at least some Marvel-chipset NICs it is harmful.
206256If the line does not improve system performance, then remove it.
0 commit comments