geneve: Allow binding UDP socket to a specific address.
Subsystems (3)
v4 cover geneve: Allow binding UDP socket to a specific address.
By default, a GENEVE device bind()s its underlying UDP socket(s) to the IPv4 or IPv6 wildcard address because there is no way to specify a specific local IP address to bind() to.
This prevents deploying multiple GENEVE devices on a multi-homed host where each device should be isolated and bound to a different local IP address on the same UDP port.
This series introduces two options to specify local IPv4 or IPv6 addresses for a GENEVE device.
The corresponding iproute2 patch is here:
https://lore.kernel.org/netdev/[email protected]/
Once this series and the iproute2 patch land upstream, I'll add a small selftest.
Changes:
v4:
* Patch 5 : Simplify validation in geneve_nl2info() : Add ynl spec
v3: https://lore.kernel.org/netdev/[email protected]/
* Patch 5 : Use NLA_POLICY_EXACT_LEN() for IFLA_GENEVE_LOCAL6. Mention source address in error messages in geneve_configure().
v2: https://lore.kernel.org/netdev/[email protected]/
* Patch 1 : Move addr_type to if-block for CONFIG_IPV6=n
* Patch 4 : Don't set cfg->dualstack for IFLA_GENEVE_REMOTE6?
* Patch 5 : Validate saddr in geneve_xmit_skb() and geneve6_xmit_skb().
v1: https://lore.kernel.org/netdev/[email protected]/
Kuniyuki Iwashima (5):
geneve: Reuse ipv6_addr_type() result in geneve_nl2info().
geneve: Pass struct geneve_dev to geneve_create_sock().
geneve: Pass struct geneve_dev to geneve_find_sock().
geneve: Add dualstack flag to struct geneve_config.
geneve: Introduce IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
Documentation/netlink/specs/rt-link.yaml | 9 + drivers/net/geneve.c | 240 ++++++++++++++++++----- include/uapi/linux/if_link.h | 2 + 3 files changed, 205 insertions(+), 46 deletions(-)
Signature · 1 line
2.54.0.794.g4f17f83d09-goog
PATCH v4 1/5 geneve: Reuse ipv6_addr_type() result in geneve_nl2info().
geneve_nl2info() calls ipv6_addr_type() to check if the remote IPv6 address is link-local.
Then, it also calls ipv6_addr_is_multicast() for the same address.
Let's not call ipv6_addr_is_multicast() and reuse ipv6_addr_type().
---
v2: Move addr_type to if-block for CONFIG_IPV6=n
--- drivers/net/geneve.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/geneve.c +5 -3
@@ -1924,6 +1924,8 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],if (data[IFLA_GENEVE_REMOTE6 ]) {#if IS_ENABLED (CONFIG_IPV6 ) +int addr_type; +if (changelink && (ip_tunnel_info_af (info) ==AF_INET )) { attrtype =IFLA_GENEVE_REMOTE6 ; goto change_notsup;
@@ -1933,13 +1935,13 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[], info->key.u.ipv6.dst =nla_get_in6_addr (data[IFLA_GENEVE_REMOTE6 ]); -if (ipv6_addr_type (&info->key.u.ipv6.dst) & -IPV6_ADDR_LINKLOCAL ) { + addr_type =ipv6_addr_type (&info->key.u.ipv6.dst); +if (addr_type &IPV6_ADDR_LINKLOCAL ) {NL_SET_ERR_MSG_ATTR (extack, data[IFLA_GENEVE_REMOTE6 ],"Remote IPv6 address cannot be link-local" );return -EINVAL ; } -if (ipv6_addr_is_multicast (&info->key.u.ipv6.dst)) { +if (addr_type &IPV6_ADDR_MULTICAST ) {NL_SET_ERR_MSG_ATTR (extack, data[IFLA_GENEVE_REMOTE6 ],"Remote IPv6 address cannot be Multicast" );return -EINVAL ;
Signature · 1 line
2.54.0.794.g4f17f83d09-goog
PATCH v4 2/5 geneve: Pass struct geneve_dev to geneve_create_sock().
In reply to Kuniyuki IwashimaThis is a prep patch to make a subsequent patch clean.
We will need to access geneve_dev->cfg.info.key.u.{ipv4,ipv6}.src in geneve_create_sock() later.
Let's pass down struct geneve_dev from geneve_sock_add() to geneve_create_sock() instead of individual config fields.
--- drivers/net/geneve.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/geneve.c +9 -9
@@ -760,9 +760,10 @@ static int geneve_udp_encap_err_lookup(struct sock *sk, struct sk_buff *skb)return -EPFNOSUPPORT ; } -static struct sock *geneve_create_sock (struct net *net,bool ipv6, -__be16 port,bool ipv6_rx_csum) +static struct sock *geneve_create_sock (struct net *net, +struct geneve_dev *geneve,bool ipv6) { +struct ip_tunnel_info *info = &geneve->cfg.info;struct udp_port_cfg udp_conf;struct socket *sock;int err;
@@ -772,13 +773,13 @@ static struct sock *geneve_create_sock(struct net *net, bool ipv6,if (ipv6) { udp_conf.family =AF_INET6 ; udp_conf.ipv6_v6only =1 ; - udp_conf.use_udp6_rx_checksums = ipv6_rx_csum; + udp_conf.use_udp6_rx_checksums = geneve->cfg.use_udp6_rx_checksums; }else { udp_conf.family =AF_INET ; udp_conf.local_ip.s_addr =htonl (INADDR_ANY ); } - udp_conf.local_udp_port = port; + udp_conf.local_udp_port = info->key.tp_dst;/* Open UDP socket */ err =udp_sock_create (net, &udp_conf, &sock);
@@ -970,8 +971,8 @@ static int geneve_gro_complete(struct sock *sk, struct sk_buff *skb, }/* Create new listen socket if needed */ -static struct geneve_sock *geneve_socket_create (struct net *net,__be16 port, -bool ipv6,bool ipv6_rx_csum) +static struct geneve_sock *geneve_socket_create (struct net *net, +struct geneve_dev *geneve,bool ipv6) {struct geneve_net *gn =net_generic (net, geneve_net_id);struct udp_tunnel_sock_cfg tunnel_cfg;
@@ -983,7 +984,7 @@ static struct geneve_sock *geneve_socket_create(struct net *net, __be16 port,if (!gs)return ERR_PTR (-ENOMEM ); - sk =geneve_create_sock (net, ipv6, port, ipv6_rx_csum); + sk =geneve_create_sock (net, geneve, ipv6);if (IS_ERR (sk)) {kfree (gs);return ERR_CAST (sk);
@@ -1073,8 +1074,7 @@ static int geneve_sock_add(struct geneve_dev *geneve, bool ipv6) goto out; } - gs =geneve_socket_create (net, geneve->cfg.info.key.tp_dst, ipv6, - geneve->cfg.use_udp6_rx_checksums); + gs =geneve_socket_create (net, geneve, ipv6);if (IS_ERR (gs))return PTR_ERR (gs);
Signature · 1 line
2.54.0.794.g4f17f83d09-goog
PATCH v4 3/5 geneve: Pass struct geneve_dev to geneve_find_sock().
In reply to Kuniyuki IwashimaThis is a prep patch to make a subsequent patch clean.
We will need to access geneve_dev->cfg.info.key.u.{ipv4,ipv6}.src in geneve_find_sock() later and extend conditions there.
Let's pass down struct geneve from geneve_sock_add() to geneve_find_sock() and flatten the conditional logic.
--- drivers/net/geneve.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)
drivers/net/geneve.c +20 -14
@@ -1040,35 +1040,41 @@ static void geneve_sock_release(struct geneve_dev *geneve)#endif } -static struct geneve_sock *geneve_find_sock (struct geneve_net *gn, -sa_family_t family, -__be16 dst_port, -bool gro_hint) +static struct geneve_sock *geneve_find_sock (struct net *net, +struct geneve_dev *geneve,bool ipv6) { +struct geneve_net *gn =net_generic (net, geneve_net_id); +struct ip_tunnel_info *info = &geneve->cfg.info; +sa_family_t family = ipv6 ?AF_INET6 :AF_INET ; +bool gro_hint = geneve->cfg.gro_hint; +__be16 dst_port = info->key.tp_dst;struct geneve_sock *gs;list_for_each_entry (gs, &gn->sock_list, list) { -if (inet_sk (gs->sk)->inet_sport == dst_port && -geneve_get_sk_family (gs) == family && - gs->gro_hint == gro_hint) { -return gs; - } +if (inet_sk (gs->sk)->inet_sport != dst_port) +continue ; + +if (geneve_get_sk_family (gs) != family) +continue ; + +if (gs->gro_hint != gro_hint) +continue ; + +return gs; } +return NULL ; }static int geneve_sock_add (struct geneve_dev *geneve,bool ipv6) {struct net *net = geneve->net; -struct geneve_net *gn =net_generic (net, geneve_net_id); -bool gro_hint = geneve->cfg.gro_hint;struct geneve_dev_node *node;struct geneve_sock *gs;__u8 vni[3 ];__u32 hash; - gs =geneve_find_sock (gn, ipv6 ?AF_INET6 :AF_INET , - geneve->cfg.info.key.tp_dst, gro_hint); + gs =geneve_find_sock (net, geneve, ipv6);if (gs) { gs->refcnt++; goto out;
@@ -1080,7 +1086,7 @@ static int geneve_sock_add(struct geneve_dev *geneve, bool ipv6) out: gs->collect_md = geneve->cfg.collect_md; - gs->gro_hint = gro_hint; + gs->gro_hint = geneve->cfg.gro_hint;#if IS_ENABLED (CONFIG_IPV6 )if (ipv6) {rcu_assign_pointer (geneve->sock6, gs);
Signature · 1 line
2.54.0.794.g4f17f83d09-goog
PATCH v4 4/5 geneve: Add dualstack flag to struct geneve_config.
In reply to Kuniyuki IwashimaWhen collect metadata mode (IFLA_GENEVE_COLLECT_METADATA) is enabled, the GENEVE device creates both IPv4 and IPv6 sockets and bind()s them to wildcard addresses.
The next patch allows creating only one socket bound to a specific address even when the collect metadata mode is enabled.
Then, we need a flag to distinguish dualstack GENEVE devices to detect local address conflict.
Let's add the dualstack flag to struct geneve_config.
IFLA_GENEVE_COLLECT_METADATA processing is moved up in geneve_nl2info() for the next patch to overwrite dualstack to false while keeping collect_md true.
Note that IFLA_GENEVE_REMOTE and IFLA_GENEVE_REMOTE6 does not set cfg->dualstack to false since is_tnl_info_zero() ignores the wildcard remote address:
# ip link add geneve0 type geneve external remote 0.0.0.1 Error: Device is externally controlled, so attributes (VNI, Port, and so on) must not be specified.
# ip link add geneve0 type geneve external remote 0.0.0.0 # ss -ua | grep geneve UNCONN 0 0 0.0.0.0:geneve 0.0.0.0:* UNCONN 0 0 *:geneve *:*
---
v2: Don't set cfg->dualstack for IFLA_GENEVE_REMOTE6?
--- drivers/net/geneve.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/net/geneve.c +16 -11
@@ -73,6 +73,7 @@ struct geneve_dev_node {struct geneve_config {bool collect_md; +bool dualstack;bool use_udp6_rx_checksums;bool ttl_inherit;bool gro_hint;
@@ -1108,12 +1109,12 @@ static int geneve_sock_add(struct geneve_dev *geneve, bool ipv6)static int geneve_open (struct net_device *dev) {struct geneve_dev *geneve =netdev_priv (dev); -bool metadata = geneve->cfg.collect_md; +bool dualstack = geneve->cfg.dualstack;bool ipv4, ipv6;int ret =0 ; - ipv6 = geneve->cfg.info.mode &IP_TUNNEL_INFO_IPV6 || metadata; - ipv4 = !ipv6 || metadata; + ipv6 = geneve->cfg.info.mode &IP_TUNNEL_INFO_IPV6 || dualstack; + ipv4 = !ipv6 || dualstack;#if IS_ENABLED (CONFIG_IPV6 )if (ipv6) { ret =geneve_sock_add (geneve, true);
@@ -1906,6 +1907,16 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],struct ip_tunnel_info *info = &cfg->info;int attrtype; +if (data[IFLA_GENEVE_COLLECT_METADATA ]) { +if (changelink) { + attrtype =IFLA_GENEVE_COLLECT_METADATA ; + goto change_notsup; + } + + cfg->collect_md = true; + cfg->dualstack = true; + } +if (data[IFLA_GENEVE_REMOTE ] && data[IFLA_GENEVE_REMOTE6 ]) {NL_SET_ERR_MSG (extack,"Cannot specify both IPv4 and IPv6 Remote addresses" );
@@ -2025,14 +2036,6 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[], cfg->port_max =ntohs (p->high); } -if (data[IFLA_GENEVE_COLLECT_METADATA ]) { -if (changelink) { - attrtype =IFLA_GENEVE_COLLECT_METADATA ; - goto change_notsup; - } - cfg->collect_md = true; - } -if (data[IFLA_GENEVE_UDP_CSUM ]) {if (changelink) { attrtype =IFLA_GENEVE_UDP_CSUM ;
@@ -2153,6 +2156,7 @@ static int geneve_newlink(struct net_device *dev, .use_udp6_rx_checksums = false, .ttl_inherit = false, .collect_md = false, + .dualstack = false, .port_min = 1, .port_max = USHRT_MAX, };
@@ -2382,6 +2386,7 @@ struct net_device *geneve_dev_create_fb(struct net *net, const char *name, .use_udp6_rx_checksums = true, .ttl_inherit = false, .collect_md = true, + .dualstack = true, .port_min = 1, .port_max = USHRT_MAX, };
Signature · 1 line
2.54.0.794.g4f17f83d09-goog
PATCH v4 5/5 geneve: Introduce IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
In reply to Kuniyuki IwashimaBy default, a GENEVE device bind()s its underlying UDP socket(s) to the IPv4 or IPv6 wildcard address because there is no way to specify a specific local IP address to bind() to.
This prevents deploying multiple GENEVE devices on a multi-homed host where each device should be isolated and bound to a different local IP address on the same UDP port.
Let's introduce new options, IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6, to allow specifying a local IPv4/IPv6 address for the backend UDP socket.
By default, when collect metadata mode (IFLA_GENEVE_COLLECT_METADATA) is enabled, both IPv4 and IPv6 sockets are created. However, if a source address is specified via the new attributes, only a single socket corresponding to that specific address family is created.
Accordingly, geneve_find_sock() and geneve_find_dev() are updated to take the source address into account, ensuring that multiple devices and sockets configured with different source addresses can coexist without conflict.
In addition, the source address is validated in geneve_xmit_skb() and geneve6_xmit_skb(), so the BPF prog must set it in bpf_tunnel_key.
With this change, multiple GENEVE devices can be successfully created and bound to their respective local IP addresses:
(*) "local" is the keyword for IFLA_GENEVE_LOCAL / IFLA_GENEVE_LOCAL6
# for i in $(seq 1 2);
do
ip link add geneve4_${i} type geneve local 192.168.0.${i} external
ip addr add 192.168.0.${i}/24 dev geneve4_${i}
ip link set geneve4_${i} up ip link add geneve6_${i} type geneve local 2001:9292::${i} external
ip addr add 2001:9292::${i}/64 dev geneve6_${i} nodad
ip link set geneve6_${i} updone
# ip -d l | grep geneve
9: geneve4_1: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
geneve external id 0 local 192.168.0.1 ...
10: geneve6_1: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
geneve external id 0 local 2001:9292::1 ...
11: geneve4_2: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
geneve external id 0 local 192.168.0.2 ...
12: geneve6_2: <BROADCAST,MULTICAST,UP,LOWER_UP> ...
geneve external id 0 local 2001:9292::2 ...# ss -ua | grep geneve UNCONN 0 0 192.168.0.2:geneve 0.0.0.0:* UNCONN 0 0 192.168.0.1:geneve 0.0.0.0:* UNCONN 0 0 [2001:9292::2]:geneve *:* UNCONN 0 0 [2001:9292::1]:geneve *:*
ynl example:
# ./tools/net/ynl/pyynl/cli.py \
--spec ./Documentation/netlink/specs/rt-link.yaml \
--do newlink --create \
--json '{"ifname": "geneve0",
"linkinfo": {"kind":"geneve",
"data": {"local": "10.0.0.1",
"collect-metadata": true}}}'---
iproute2 patch is here:
https://lore.kernel.org/netdev/[email protected]/
Changelog:
v4:
* Simplify validation in geneve_nl2info()
* Add ynl spec
v3:
* Use NLA_POLICY_EXACT_LEN() for IFLA_GENEVE_LOCAL6.
* Mention source address in error messages in geneve_configure().
v2:
* Move addr_type to if-block for CONFIG_IPV6=n.
* Validate saddr in geneve_xmit_skb() and geneve6_xmit_skb().
--- Documentation/netlink/specs/rt-link.yaml | 9 ++ drivers/net/geneve.c | 153 +++++++++++++++++++++-- include/uapi/linux/if_link.h | 2 + 3 files changed, 155 insertions(+), 9 deletions(-)
Documentation/netlink/specs/rt-link.yaml +9 -0
@@ -1939,6 +1939,15 @@ attribute-sets: - name: gro-hint type: flag + - + name: local + type: u32 + byte-order: big-endian + display-hint: ipv4 + - + name: local6 + type: binary + display-hint: ipv6 - name: linkinfo-hsr-attrs name-prefix: ifla-hsr-
drivers/net/geneve.c +144 -9
246 lines not on this page · raw message
include/uapi/linux/if_link.h +2 -0
@@ -1506,6 +1506,8 @@ enum {IFLA_GENEVE_INNER_PROTO_INHERIT ,IFLA_GENEVE_PORT_RANGE ,IFLA_GENEVE_GRO_HINT , +IFLA_GENEVE_LOCAL , +IFLA_GENEVE_LOCAL6 , __IFLA_GENEVE_MAX };#define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1)
Signature · 1 line
2.54.0.794.g4f17f83d09-goog
Jakub Kicinski
maintainerRe: [PATCH v4 net-next 5/5] geneve: Introduce IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
geneve: Introduce IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
This patch adds IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6 attributes so a GENEVE device's underlying UDP socket can be bound to a specific local IPv4 or IPv6 address rather than the wildcard, and updates lookup paths and xmit paths accordingly.
Quoted 4 lines
drivers/net/geneve.c +0
-0
[ ... ]
Quoted 19 lines
drivers/net/geneve.c +15
-0@@ -1972,6 +2043,55 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],#endif } +if (data[IFLA_GENEVE_LOCAL ]) { +if (changelink) { + attrtype =IFLA_GENEVE_LOCAL ; + goto change_notsup; + } + + info->key.u.ipv4.src =nla_get_in_addr (data[IFLA_GENEVE_LOCAL ]); + +if (ipv4_is_multicast (info->key.u.ipv4.src)) { +NL_SET_ERR_MSG_ATTR (extack, data[IFLA_GENEVE_LOCAL ], +"Local IPv4 address cannot be Multicast" ); +return -EINVAL ; + } + + cfg->dualstack = false;
drivers/net/geneve.c static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[], · line 2070
Quoted 10 lines
drivers/net/geneve.c +10
-0+ } + +if (data[IFLA_GENEVE_LOCAL6 ]) { +#if IS_ENABLED (CONFIG_IPV6 ) +int addr_type; + +if (changelink) { + attrtype =IFLA_GENEVE_LOCAL6 ; + goto change_notsup; + }
[Medium]
Should the changelink rejection here mirror the IFLA_GENEVE_REMOTE behavior in this same function? IFLA_GENEVE_REMOTE only fails the changelink when the family changes:
if (data[IFLA_GENEVE_REMOTE]) {
if (changelink && (ip_tunnel_info_af(info) == AF_INET6)) {
attrtype = IFLA_GENEVE_REMOTE;
goto change_notsup;
}whereas IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6 fail unconditionally whenever the attribute is present, even when the value matches the existing configuration.
Combined with the geneve_fill_info() change below, would this break the common dump-then-changelink round trip used by some management tools on pre-existing devices, returning -EOPNOTSUPP even though LOCAL was never explicitly configured?
[ ... ]
Quoted 8 lines
drivers/net/geneve.c +4
-0@@ -2320,6 +2441,20 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)#endif } +if (!geneve->cfg.dualstack) { +if (ip_tunnel_info_af (info) ==AF_INET ) { +if (nla_put_in_addr (skb,IFLA_GENEVE_LOCAL , + info->key.u.ipv4.src))
drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 2457
Quoted 10 lines
drivers/net/geneve.c +10
-0+ goto nla_put_failure; +#if IS_ENABLED (CONFIG_IPV6 ) + } else { +if (nla_put_in6_addr (skb,IFLA_GENEVE_LOCAL6 , + &info->key.u.ipv6.src)) + goto nla_put_failure; +#endif + } + } +
[Medium]
Does this emit IFLA_GENEVE_LOCAL or IFLA_GENEVE_LOCAL6 on every non-collect_md device, including legacy devices created without any local address?
cfg->dualstack is only set true for collect_md devices, so for any device where the user never specified a local address, info->key.u.ipv4.src is 0 (or info->key.u.ipv6.src is ::) but the attribute is still emitted. This would change the visible output of ip -d link show and netlink dumps for existing GENEVE devices, adding a synthetic local 0.0.0.0 or local :: that was not present before.
Would gating this on a non-zero source address (or tracking whether the user explicitly set LOCAL) avoid the dump-output change for unaffected devices?
The commit message describes the new behavior on devices that set LOCAL/LOCAL6 but does not mention that fill_info now emits these attributes for every previously-created non-collect_md device, nor that changelink will reject any presence of LOCAL/LOCAL6 even when the value is unchanged. Could the commit message call out these compatibility implications?
Re: [PATCH v4 net-next 5/5] geneve: Introduce IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
Quoted 44 lines · Jakub Kicinski
This is an AI-generated review of your patch. The human sending this email has considered the AI review valid, or at least plausible.
---
geneve: IntroduceIFLA_GENEVE_LOCALandIFLA_GENEVE_LOCAL6.This patch adds
IFLA_GENEVE_LOCALandIFLA_GENEVE_LOCAL6attributes so a GENEVE device's underlying UDP socket can be bound to a specific local IPv4 or IPv6 address rather than the wildcard, and updates lookup paths and xmit paths accordingly.Quoted 4 lines
drivers/net/geneve.c +0
-0[ ... ]
Quoted 26 lines
drivers/net/geneve.c +22
-0@@ -1972,6 +2043,55 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],#endif } +if (data[IFLA_GENEVE_LOCAL ]) { +if (changelink) { + attrtype =IFLA_GENEVE_LOCAL ; + goto change_notsup; + } + + info->key.u.ipv4.src =nla_get_in_addr (data[IFLA_GENEVE_LOCAL ]); + +if (ipv4_is_multicast (info->key.u.ipv4.src)) { +NL_SET_ERR_MSG_ATTR (extack, data[IFLA_GENEVE_LOCAL ], +"Local IPv4 address cannot be Multicast" ); +return -EINVAL ; + } + + cfg->dualstack = false; + } + +if (data[IFLA_GENEVE_LOCAL6 ]) { +#if IS_ENABLED (CONFIG_IPV6 ) +int addr_type; + +if (changelink) {
Quoted 8 lines
drivers/net/geneve.c static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[], · line 2070
Quoted 3 lines
drivers/net/geneve.c +3
-0+ attrtype =IFLA_GENEVE_LOCAL6 ; + goto change_notsup; + }[Medium]
Should the changelink rejection here mirror theIFLA_GENEVE_REMOTEbehavior in this same function?IFLA_GENEVE_REMOTEonly fails the changelink when the family changes:
REMOTE can be changed easily for each xmit, but LOCAL requires re-bind(), which would unnecessarily complicate the code, so I just disallowed changelink for simplicity.
Quoted 49 lines
if (data[IFLA_GENEVE_REMOTE]) { if (changelink && (ip_tunnel_info_af(info) == AF_INET6)) { attrtype = IFLA_GENEVE_REMOTE; goto change_notsup; }whereas
IFLA_GENEVE_LOCALandIFLA_GENEVE_LOCAL6fail unconditionally whenever the attribute is present, even when the value matches the existing configuration.Combined with the
geneve_fill_info()change below, would this break the common dump-then-changelink round trip used by some management tools on pre-existing devices, returning-EOPNOTSUPPeven though LOCAL was never explicitly configured?[ ... ]
Quoted 8 lines
drivers/net/geneve.c +4
-0@@ -2320,6 +2441,20 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)#endif } +if (!geneve->cfg.dualstack) { +if (ip_tunnel_info_af (info) ==AF_INET ) { +if (nla_put_in_addr (skb,IFLA_GENEVE_LOCAL , + info->key.u.ipv4.src))drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 2457
Quoted 10 lines
drivers/net/geneve.c +10
-0+ goto nla_put_failure; +#if IS_ENABLED (CONFIG_IPV6 ) + } else { +if (nla_put_in6_addr (skb,IFLA_GENEVE_LOCAL6 , + &info->key.u.ipv6.src)) + goto nla_put_failure; +#endif + } + } +[Medium]
Does this emitIFLA_GENEVE_LOCALorIFLA_GENEVE_LOCAL6on every non-collect_md device, including legacy devices created without any local address?
cfg->dualstackis only set true forcollect_mddevices, so for any device where the user never specified a local address,info->key.u.ipv4.srcis 0 (orinfo->key.u.ipv6.srcis ::) but the attribute is still emitted. This would change the visible output of ip -d link show and netlink dumps for existing GENEVE devices, adding a synthetic local 0.0.0.0 or local :: that was not present before.
Quoted 3 lines
Would gating this on a non-zero source address (or tracking whether the user explicitly set LOCAL) avoid the dump-output change for unaffected devices?
Honestly I don't have strong preference on this.
New iproute2 will show 0.0.0.0 or :: even for devices created without the attribute indeed, but I guess it's almost always the case that the dump command shows every attribute when we add a new one...?
Quoted 7 lines
The commit message describes the new behavior on devices that set LOCAL/LOCAL6 but does not mention that
fill_infonow emits these attributes for every previously-created non-collect_md device, nor that changelink will reject any presence of LOCAL/LOCAL6 even when the value is unchanged. Could the commit message call out these compatibility implications?
Jakub Kicinski
maintainerRe: [PATCH v4 net-next 5/5] geneve: Introduce IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
Quoted 15 lines · On Mon, 1 Jun 2026 20:25:24 -0700 Kuniyuki Iwashima wrote:
Quoted 11 lines
Does this emit
IFLA_GENEVE_LOCALorIFLA_GENEVE_LOCAL6on every non-collect_md device, including legacy devices created without any local address?
cfg->dualstackis only set true forcollect_mddevices, so for any device where the user never specified a local address,info->key.u.ipv4.srcis 0 (orinfo->key.u.ipv6.srcis ::) but the attribute is still emitted. This would change the visible output of ip -d link show and netlink dumps for existing GENEVE devices, adding a synthetic local 0.0.0.0 or local :: that was not present before.Quoted 3 lines
Would gating this on a non-zero source address (or tracking whether the user explicitly set LOCAL) avoid the dump-output change for unaffected devices?
Quoted 5 lines
Honestly I don't have strong preference on this.
New iproute2 will show 0.0.0.0 or :: even for devices created without the attribute indeed, but I guess it's almost always the case that the dump command shows every attribute when we add a new one...?
IDK if there's any strong reason one way or the other, but my understanding was that we try to only dump back the optional attributes which were actually set by the user.
Whether we follow that here or not is less important, but I think the bot makes a legitimate point. If we default to dumping zeros even if user never set the addr - we should allow user echoing back already set values in changelink.
IOW the ask is not to rebind but to compare the addr to current one in changelink.
Re: [PATCH v4 net-next 5/5] geneve: Introduce IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
Quoted 27 lines · Jakub Kicinski
Quoted 15 lines · On Mon, 1 Jun 2026 20:25:24 -0700 Kuniyuki Iwashima wrote:
Quoted 11 lines
Does this emit
IFLA_GENEVE_LOCALorIFLA_GENEVE_LOCAL6on every non-collect_md device, including legacy devices created without any local address?
cfg->dualstackis only set true forcollect_mddevices, so for any device where the user never specified a local address,info->key.u.ipv4.srcis 0 (orinfo->key.u.ipv6.srcis ::) but the attribute is still emitted. This would change the visible output of ip -d link show and netlink dumps for existing GENEVE devices, adding a synthetic local 0.0.0.0 or local :: that was not present before.Quoted 3 lines
Would gating this on a non-zero source address (or tracking whether the user explicitly set LOCAL) avoid the dump-output change for unaffected devices?
Quoted 5 lines
Honestly I don't have strong preference on this.
New iproute2 will show 0.0.0.0 or :: even for devices created without the attribute indeed, but I guess it's almost always the case that the dump command shows every attribute when we add a new one...?
IDK if there's any strong reason one way or the other, but my understanding was that we try to only dump back the optional attributes which were actually set by the user.
Quoted 7 lines
Whether we follow that here or not is less important, but I think the bot makes a legitimate point. If we default to dumping zeros even if user never set the addr - we should allow user echoing back already set values in changelink.
IOW the ask is not to rebind but to compare the addr to current one in changelink.
Ah okay, I'll apply both changes, thanks !
--
pw-bot: cr