ip: add AMT support
Subsystems (2)
PATCH v2 1/1 ip: add AMT support
Add basic support for Automatic Multicast Tunneling (AMT) network devices.
---
v1 -> v2:
- Remove unnecessary check
- Use strcmp() instead of matches().
ip/Makefile | 3 +- ip/ip.c | 4 +- ip/iplink.c | 2 +- ip/iplink_amt.c | 224 ++++++++++++++++++++++++++++++++++++++++++ man/man8/ip-link.8.in | 46 +++++++++ 5 files changed, 275 insertions(+), 4 deletions(-) create mode 100644 ip/iplink_amt.c
ip/Makefile +2 -1
@@ -11,7 +11,8 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \ iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \ iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \ ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o \ - ipnexthop.o ipmptcp.o iplink_bareudp.o iplink_wwan.o ipioam6.o + ipnexthop.o ipmptcp.o iplink_bareudp.o iplink_wwan.o ipioam6.o \ + iplink_amt.o RTMONOBJ=rtmon.o
ip/ip.c +2 -2
@@ -64,8 +64,8 @@ static void usage(void)fprintf (stderr,"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n" " ip [ -force ] -batch filename\n" -"where OBJECT := { address | addrlabel | fou | help | ila | ioam | l2tp | link |\n" -" macsec | maddress | monitor | mptcp | mroute | mrule |\n" +"where OBJECT := { address | addrlabel | amt | fou | help | ila | ioam | l2tp |\n" +" link | macsec | maddress | monitor | mptcp | mroute | mrule |\n" " neighbor | neighbour | netconf | netns | nexthop | ntable |\n" " ntbl | route | rule | sr | tap | tcpmetrics |\n" " token | tunnel | tuntap | vrf | xfrm }\n"
ip/iplink.c +1 -1
@@ -50,7 +50,7 @@ void iplink_types_usage(void) {/* Remember to add new entry here if new type is added. */ fprintf (stderr, -"TYPE := { bareudp | bond | bond_slave | bridge | bridge_slave |\n" +"TYPE := { amt | bareudp | bond | bond_slave | bridge | bridge_slave |\n" " dummy | erspan | geneve | gre | gretap | ifb |\n" " ip6erspan | ip6gre | ip6gretap | ip6tnl |\n" " ipip | ipoib | ipvlan | ipvtap |\n"
ip/iplink_amt.c new file +224 -0
224 lines not on this page · raw message
man/man8/ip-link.8.in +46 -0
64 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 24 lines · Taehee Yoo
ip/iplink_amt.c new file +24
-0+static void amt_print_opt (struct link_util *lu,FILE *f,struct rtattr *tb[]) +{ +if (!tb) +return ; + +if (tb[IFLA_AMT_MODE ]) { +print_string (PRINT_ANY , +"mode" , +"%s " , + modename[rta_getattr_u32 (tb[IFLA_AMT_MODE ])]); + } + +if (tb[IFLA_AMT_GATEWAY_PORT ]) { +print_uint (PRINT_ANY , +"gateway_port" , +"gateway_port %u " , +rta_getattr_be16 (tb[IFLA_AMT_GATEWAY_PORT ])); + } + +if (tb[IFLA_AMT_RELAY_PORT ]) { +print_uint (PRINT_ANY , +"relay_port" , +"relay_port %u " , +rta_getattr_be16 (tb[IFLA_AMT_RELAY_PORT ]));
ip/iplink_amt.c line 172
Quoted 10 lines
ip/iplink_amt.c new file +10
-0+ } + +if (tb[IFLA_AMT_LOCAL_IP ]) { +__be32 addr =rta_getattr_u32 (tb[IFLA_AMT_LOCAL_IP ]); + +if (addr) +print_string (PRINT_ANY , +"local" , +"local %s " , +format_host (AF_INET ,4 , &addr));
if you only print the address when it is non-zero, why send it at all? ie., kernel side can default to 0 (any address) but that value should not be allowed or sent as part of the API. Same with the remote and discovery addresses.
Quoted 19 lines
ip/iplink_amt.c new file +19
-0+ } + +if (tb[IFLA_AMT_REMOTE_IP ]) { +__be32 addr =rta_getattr_u32 (tb[IFLA_AMT_REMOTE_IP ]); + +if (addr) +print_string (PRINT_ANY , +"remote" , +"remote %s " , +format_host (AF_INET ,4 , &addr)); + } + +if (tb[IFLA_AMT_DISCOVERY_IP ]) { +__be32 addr =rta_getattr_u32 (tb[IFLA_AMT_DISCOVERY_IP ]); + +if (addr) { + print_string(PRINT_ANY, + "discovery", + "discovery %s ",
ip/iplink_amt.c line 201
Quoted 10 lines
ip/iplink_amt.c new file +10
-0+ format_host(AF_INET, 4, &addr)); + } + } + +if (tb[IFLA_AMT_LINK ]) { +unsigned int link =rta_getattr_u32 (tb[IFLA_AMT_LINK ]); + +if (link) +print_string (PRINT_ANY ,"link" ,"dev %s " , +ll_index_to_name (link));
similar argument here: IFLA_AMT_LINK should only be sent if an actual link association is configured.
ip/iplink_amt.c line 209
Quoted 8 lines
ip/iplink_amt.c new file +8
-0+ } + +if (tb[IFLA_AMT_MAX_TUNNELS ]) { +unsigned int tunnels =rta_getattr_u32 (tb[IFLA_AMT_MAX_TUNNELS ]); + +if (tunnels) +print_uint (PRINT_ANY ,"max_tunnels" ,"max_tunnels %u " , +rta_getattr_u32 (tb[IFLA_AMT_MAX_TUNNELS ]));
and here.
Quoted 3 lines
ip/iplink_amt.c new file +3
-0+ } +} +
Hi David,
Thank you for your review!
Quoted 32 lines · David Ahern
Quoted 31 lines · Taehee Yoo
ip/iplink_amt.c new file +31
-0+static void amt_print_opt (struct link_util *lu,FILE *f,struct rtattr *tb[]) +{ +if (!tb) +return ; + +if (tb[IFLA_AMT_MODE ]) { +print_string (PRINT_ANY , +"mode" , +"%s " , + modename[rta_getattr_u32 (tb[IFLA_AMT_MODE ])]); + } + +if (tb[IFLA_AMT_GATEWAY_PORT ]) { +print_uint (PRINT_ANY , +"gateway_port" , +"gateway_port %u " , +rta_getattr_be16 (tb[IFLA_AMT_GATEWAY_PORT ])); + } + +if (tb[IFLA_AMT_RELAY_PORT ]) { +print_uint (PRINT_ANY , +"relay_port" , +"relay_port %u " , +rta_getattr_be16 (tb[IFLA_AMT_RELAY_PORT ])); + } + +if (tb[IFLA_AMT_LOCAL_IP ]) { +__be32 addr =rta_getattr_u32 (tb[IFLA_AMT_LOCAL_IP ]); + +if (addr) + print_string(PRINT_ANY,
Quoted 9 lines
ip/iplink_amt.c line 172
Quoted 3 lines
ip/iplink_amt.c new file +3
-0+"local" , +"local %s " , + format_host(AF_INET, 4, &addr));if you only print the address when it is non-zero, why send it at all? ie., kernel side can default to 0 (any address) but that value should not be allowed or sent as part of the API. Same with the remote and discovery addresses.
Thanks, I will remove this check and I will add ipv4_is_zeronet() to the kernel.
Quoted 24 lines
Quoted 24 lines
ip/iplink_amt.c new file +24
-0+ } + +if (tb[IFLA_AMT_REMOTE_IP ]) { +__be32 addr =rta_getattr_u32 (tb[IFLA_AMT_REMOTE_IP ]); + +if (addr) +print_string (PRINT_ANY , +"remote" , +"remote %s " , +format_host (AF_INET ,4 , &addr)); + } + +if (tb[IFLA_AMT_DISCOVERY_IP ]) { +__be32 addr =rta_getattr_u32 (tb[IFLA_AMT_DISCOVERY_IP ]); + +if (addr) { +print_string (PRINT_ANY , +"discovery" , +"discovery %s " , +format_host (AF_INET ,4 , &addr)); + } + } + +if (tb[IFLA_AMT_LINK ]) {
Quoted 9 lines
ip/iplink_amt.c line 201
Quoted 5 lines
ip/iplink_amt.c new file +5
-0+unsigned int link =rta_getattr_u32 (tb[IFLA_AMT_LINK ]); + +if (link) +print_string (PRINT_ANY ,"link" ,"dev %s " , +ll_index_to_name (link));similar argument here:
IFLA_AMT_LINKshould only be sent if an actual link association is configured.
Thanks, I will remove it too.
Quoted 11 lines
ip/iplink_amt.c line 209
Quoted 8 lines
ip/iplink_amt.c new file +8
-0+ } + +if (tb[IFLA_AMT_MAX_TUNNELS ]) { +unsigned int tunnels =rta_getattr_u32 (tb[IFLA_AMT_MAX_TUNNELS ]); + +if (tunnels) +print_uint (PRINT_ANY ,"max_tunnels" ,"max_tunnels %u " , +rta_getattr_u32 (tb[IFLA_AMT_MAX_TUNNELS ]));and here.
here too.
Quoted 5 lines
ip/iplink_amt.c line 50
Quoted 3 lines
ip/iplink_amt.c new file +3
-0+ } +} +
Thanks a lot for your detailed review!
I will send the v3 patch soon.
Thanks,
Taehee