kernel-netlink: Add manager for XFRM interfaces
The manager will allow charon-nm to create XFRM interfaces if supported by the kernel instead of creating an unused dummy TUN interface. The xfrmi tool is mostly obsolete nowadays as iproute2 supports creating XFRM interfaces since 5.1.0 (2019-05). Older Debians don't ship that and early versions didn't list the interface IDs. So there might still be some uses for this tool.
This commit is contained in:
@@ -27,10 +27,10 @@ def handle_interfaces(ike_sa, up):
|
||||
|
||||
if up:
|
||||
logger.info("add XFRM interfaces %s and %s", ifname_in, ifname_out)
|
||||
subprocess.call(["/usr/local/libexec/ipsec/xfrmi", "-n", ifname_out,
|
||||
"-i", str(if_id_out), "-d", "eth0"])
|
||||
subprocess.call(["/usr/local/libexec/ipsec/xfrmi", "-n", ifname_in,
|
||||
"-i", str(if_id_in), "-d", "eth0"])
|
||||
subprocess.call(["ip", "link", "add", ifname_out, "type", "xfrm",
|
||||
"if_id", str(if_id_out), "dev", "eth0"])
|
||||
subprocess.call(["ip", "link", "add", ifname_in, "type", "xfrm",
|
||||
"if_id", str(if_id_in), "dev", "eth0"])
|
||||
subprocess.call(["ip", "link", "set", ifname_out, "up"])
|
||||
subprocess.call(["ip", "link", "set", ifname_in, "up"])
|
||||
subprocess.call(["iptables", "-A", "FORWARD", "-o", ifname_out,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
moon::iptables-restore < /etc/iptables.rules
|
||||
sun::iptables-restore < /etc/iptables.rules
|
||||
moon::/usr/local/libexec/ipsec/xfrmi -n xfrm-moon-out -d eth0 -i 1337
|
||||
moon::/usr/local/libexec/ipsec/xfrmi -n xfrm-moon-in -d eth0 -i 42
|
||||
moon::ip link add xfrm-moon-out type xfrm dev eth0 if_id 1337
|
||||
moon::ip link add xfrm-moon-in type xfrm dev eth0 if_id 42
|
||||
moon::ip link set xfrm-moon-out up
|
||||
moon::ip link set xfrm-moon-in up
|
||||
moon::ip route add 10.2.0.0/16 dev xfrm-moon-out
|
||||
|
||||
@@ -4,7 +4,7 @@ IF_NAME="xfrmi-${PLUTO_IF_ID_IN}"
|
||||
|
||||
case "${PLUTO_VERB}" in
|
||||
up-client)
|
||||
/usr/local/libexec/ipsec/xfrmi -n "${IF_NAME}" -i "${PLUTO_IF_ID_IN}" -d eth0
|
||||
ip link add "${IF_NAME}" type xfrm if_id "${PLUTO_IF_ID_IN}" dev eth0
|
||||
ip link set "${IF_NAME}" up
|
||||
ip route add 10.1.0.0/16 dev "${IF_NAME}"
|
||||
iptables -A FORWARD -i "${IF_NAME}" -j ACCEPT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
moon::iptables-restore < /etc/iptables.rules
|
||||
sun::iptables-restore < /etc/iptables.rules
|
||||
moon::/usr/local/libexec/ipsec/xfrmi -n xfrm-moon -i 42 -d eth0
|
||||
moon::ip link add xfrm-moon type xfrm if_id 42 dev eth0
|
||||
moon::ip link set xfrm-moon up
|
||||
moon::ip route add 10.2.0.0/16 dev xfrm-moon
|
||||
moon::iptables -A FORWARD -i xfrm-moon -j ACCEPT
|
||||
|
||||
@@ -6,8 +6,8 @@ IF_NAME_OUT="${IF_NAME}${PLUTO_IF_ID_OUT}-out"
|
||||
|
||||
case "${PLUTO_VERB}" in
|
||||
up-client)
|
||||
/usr/local/libexec/ipsec/xfrmi -n "${IF_NAME_OUT}" -i "${PLUTO_IF_ID_OUT}" -d eth0
|
||||
/usr/local/libexec/ipsec/xfrmi -n "${IF_NAME_IN}" -i "${PLUTO_IF_ID_IN}" -d eth0
|
||||
ip link add "${IF_NAME_OUT}" type xfrm if_id "${PLUTO_IF_ID_OUT}" dev eth0
|
||||
ip link add "${IF_NAME_IN}" type xfrm if_id "${PLUTO_IF_ID_IN}" dev eth0
|
||||
ip link set "${IF_NAME_OUT}" up
|
||||
ip link set "${IF_NAME_IN}" up
|
||||
ip route add 10.1.0.0/16 dev "${IF_NAME_OUT}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
moon::iptables-restore < /etc/iptables.rules
|
||||
sun::iptables-restore < /etc/iptables.rules
|
||||
moon::/usr/local/libexec/ipsec/xfrmi -n xfrm-moon-out -d eth0 -i 1337
|
||||
moon::/usr/local/libexec/ipsec/xfrmi -n xfrm-moon-in -d eth0 -i 42
|
||||
moon::ip link add xfrm-moon-out type xfrm dev eth0 if_id 1337
|
||||
moon::ip link add xfrm-moon-in type xfrm dev eth0 if_id 42
|
||||
moon::ip link set xfrm-moon-out up
|
||||
moon::ip link set xfrm-moon-in up
|
||||
moon::ip route add 10.2.0.0/16 dev xfrm-moon-out
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
moon::iptables-restore < /etc/iptables.rules
|
||||
carol::iptables-restore < /etc/iptables.rules
|
||||
dave::iptables-restore < /etc/iptables.rules
|
||||
moon::/usr/local/libexec/ipsec/xfrmi -n xfrm-moon -i 42 -d eth0
|
||||
moon::ip link add xfrm-moon type xfrm if_id 42 dev eth0
|
||||
moon::ip link set xfrm-moon up
|
||||
moon::ip route add 10.3.0.0/28 dev xfrm-moon
|
||||
moon::iptables -A FORWARD -i xfrm-moon -j ACCEPT
|
||||
|
||||
Reference in New Issue
Block a user