* [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
@ 2026-05-23 6:10 Kuniyuki Iwashima
2026-06-02 18:38 ` Kuniyuki Iwashima
2026-06-02 19:59 ` Stephen Hemminger
0 siblings, 2 replies; 6+ messages in thread
From: Kuniyuki Iwashima @ 2026-05-23 6:10 UTC (permalink / raw)
To: Stephen Hemminger, David Ahern
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6 allow specifying a local
IPv4/IPv6 address for the backend UDP socket of a GENEVE devcie.
Let's support the attributes with the "local" keyword.
# 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} up
done
# 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 *:*
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
The corresponding kernel patch will be posted separately.
---
include/uapi/linux/if_link.h | 2 ++
ip/iplink_geneve.c | 43 +++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index a8c64be26f2c..d692d466da6b 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -1487,6 +1487,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)
diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
index 62c61bce138b..8d21722b598c 100644
--- a/ip/iplink_geneve.c
+++ b/ip/iplink_geneve.c
@@ -18,6 +18,7 @@ static void print_explain(FILE *f)
fprintf(f,
"Usage: ... geneve id VNI\n"
" remote ADDR\n"
+ " [ local ADDR ]\n"
" [ ttl TTL ]\n"
" [ tos TOS ]\n"
" [ df DF ]\n"
@@ -56,7 +57,7 @@ static void check_duparg(__u64 *attrs, int type, const char *key,
static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
struct nlmsghdr *n)
{
- inet_prefix daddr;
+ inet_prefix daddr, saddr;
__u32 vni = 0;
__u32 label = 0;
__u8 ttl = 0;
@@ -72,6 +73,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
bool inner_proto_inherit = false;
inet_prefix_reset(&daddr);
+ inet_prefix_reset(&saddr);
while (argc > 0) {
if (!matches(*argv, "id") ||
@@ -88,6 +90,13 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
get_addr(&daddr, *argv, AF_UNSPEC);
if (!is_addrtype_inet_not_multi(&daddr))
invarg("invalid remote address", *argv);
+ } else if (!matches(*argv, "local")) {
+ NEXT_ARG();
+ check_duparg(&attrs, IFLA_GENEVE_LOCAL, "local",
+ *argv);
+ get_addr(&saddr, *argv, AF_UNSPEC);
+ if (!is_addrtype_inet_not_multi(&saddr))
+ invarg("invalid local address", *argv);
} else if (!matches(*argv, "ttl") ||
!matches(*argv, "hoplimit")) {
unsigned int uval;
@@ -221,8 +230,17 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
if (is_addrtype_inet(&daddr)) {
int type = (daddr.family == AF_INET) ? IFLA_GENEVE_REMOTE :
IFLA_GENEVE_REMOTE6;
+
addattr_l(n, 1024, type, daddr.data, daddr.bytelen);
}
+
+ if (is_addrtype_inet(&saddr)) {
+ int type = (saddr.family == AF_INET) ? IFLA_GENEVE_LOCAL :
+ IFLA_GENEVE_LOCAL6;
+
+ addattr_l(n, 1024, type, saddr.data, saddr.bytelen);
+ }
+
if (!set_op || GENEVE_ATTRSET(attrs, IFLA_GENEVE_LABEL))
addattr32(n, 1024, IFLA_GENEVE_LABEL, label);
if (!set_op || GENEVE_ATTRSET(attrs, IFLA_GENEVE_TTL))
@@ -285,6 +303,29 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
}
}
+ if (tb[IFLA_GENEVE_LOCAL]) {
+ __be32 addr = rta_getattr_u32(tb[IFLA_GENEVE_LOCAL]);
+
+ if (addr)
+ print_string(PRINT_ANY,
+ "local",
+ "local %s ",
+ format_host(AF_INET, 4, &addr));
+ } else if (tb[IFLA_GENEVE_LOCAL6]) {
+ struct in6_addr addr;
+
+ memcpy(&addr, RTA_DATA(tb[IFLA_GENEVE_LOCAL6]), sizeof(struct in6_addr));
+ if (!IN6_IS_ADDR_UNSPECIFIED(&addr)) {
+ if (!IN6_IS_ADDR_MULTICAST(&addr))
+ print_string(PRINT_ANY,
+ "local6",
+ "local %s ",
+ format_host(AF_INET6,
+ sizeof(struct in6_addr),
+ &addr));
+ }
+ }
+
if (tb[IFLA_GENEVE_TTL_INHERIT] &&
rta_getattr_u8(tb[IFLA_GENEVE_TTL_INHERIT])) {
print_string(PRINT_FP, NULL, "ttl %s ", "inherit");
--
2.54.0.746.g67dd491aae-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
2026-05-23 6:10 [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6 Kuniyuki Iwashima
@ 2026-06-02 18:38 ` Kuniyuki Iwashima
2026-06-02 19:59 ` Stephen Hemminger
1 sibling, 0 replies; 6+ messages in thread
From: Kuniyuki Iwashima @ 2026-06-02 18:38 UTC (permalink / raw)
To: Stephen Hemminger, David Ahern
Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Kuniyuki Iwashima, netdev
On Fri, May 22, 2026 at 11:11 PM Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6 allow specifying a local
> IPv4/IPv6 address for the backend UDP socket of a GENEVE devcie.
>
> Let's support the attributes with the "local" keyword.
>
> # 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} up
> done
>
> # 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 *:*
>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
> ---
> The corresponding kernel patch will be posted separately.
> ---
> include/uapi/linux/if_link.h | 2 ++
> ip/iplink_geneve.c | 43 +++++++++++++++++++++++++++++++++++-
> 2 files changed, 44 insertions(+), 1 deletion(-)
>
> diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
> index a8c64be26f2c..d692d466da6b 100644
> --- a/include/uapi/linux/if_link.h
> +++ b/include/uapi/linux/if_link.h
> @@ -1487,6 +1487,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)
> diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
> index 62c61bce138b..8d21722b598c 100644
> --- a/ip/iplink_geneve.c
> +++ b/ip/iplink_geneve.c
> @@ -18,6 +18,7 @@ static void print_explain(FILE *f)
> fprintf(f,
> "Usage: ... geneve id VNI\n"
> " remote ADDR\n"
> + " [ local ADDR ]\n"
> " [ ttl TTL ]\n"
> " [ tos TOS ]\n"
> " [ df DF ]\n"
> @@ -56,7 +57,7 @@ static void check_duparg(__u64 *attrs, int type, const char *key,
> static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
> struct nlmsghdr *n)
> {
> - inet_prefix daddr;
> + inet_prefix daddr, saddr;
> __u32 vni = 0;
> __u32 label = 0;
> __u8 ttl = 0;
> @@ -72,6 +73,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
> bool inner_proto_inherit = false;
>
> inet_prefix_reset(&daddr);
> + inet_prefix_reset(&saddr);
>
> while (argc > 0) {
> if (!matches(*argv, "id") ||
> @@ -88,6 +90,13 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
> get_addr(&daddr, *argv, AF_UNSPEC);
> if (!is_addrtype_inet_not_multi(&daddr))
> invarg("invalid remote address", *argv);
> + } else if (!matches(*argv, "local")) {
> + NEXT_ARG();
> + check_duparg(&attrs, IFLA_GENEVE_LOCAL, "local",
> + *argv);
> + get_addr(&saddr, *argv, AF_UNSPEC);
> + if (!is_addrtype_inet_not_multi(&saddr))
> + invarg("invalid local address", *argv);
> } else if (!matches(*argv, "ttl") ||
> !matches(*argv, "hoplimit")) {
> unsigned int uval;
> @@ -221,8 +230,17 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
> if (is_addrtype_inet(&daddr)) {
> int type = (daddr.family == AF_INET) ? IFLA_GENEVE_REMOTE :
> IFLA_GENEVE_REMOTE6;
> +
> addattr_l(n, 1024, type, daddr.data, daddr.bytelen);
> }
> +
> + if (is_addrtype_inet(&saddr)) {
> + int type = (saddr.family == AF_INET) ? IFLA_GENEVE_LOCAL :
> + IFLA_GENEVE_LOCAL6;
> +
> + addattr_l(n, 1024, type, saddr.data, saddr.bytelen);
> + }
> +
> if (!set_op || GENEVE_ATTRSET(attrs, IFLA_GENEVE_LABEL))
> addattr32(n, 1024, IFLA_GENEVE_LABEL, label);
> if (!set_op || GENEVE_ATTRSET(attrs, IFLA_GENEVE_TTL))
> @@ -285,6 +303,29 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
> }
> }
>
> + if (tb[IFLA_GENEVE_LOCAL]) {
> + __be32 addr = rta_getattr_u32(tb[IFLA_GENEVE_LOCAL]);
> +
> + if (addr)
I'll remove this check to match the new dump behaviour.
pw-bot: cr
> + print_string(PRINT_ANY,
> + "local",
> + "local %s ",
> + format_host(AF_INET, 4, &addr));
> + } else if (tb[IFLA_GENEVE_LOCAL6]) {
> + struct in6_addr addr;
> +
> + memcpy(&addr, RTA_DATA(tb[IFLA_GENEVE_LOCAL6]), sizeof(struct in6_addr));
> + if (!IN6_IS_ADDR_UNSPECIFIED(&addr)) {
> + if (!IN6_IS_ADDR_MULTICAST(&addr))
> + print_string(PRINT_ANY,
> + "local6",
> + "local %s ",
> + format_host(AF_INET6,
> + sizeof(struct in6_addr),
> + &addr));
> + }
> + }
> +
> if (tb[IFLA_GENEVE_TTL_INHERIT] &&
> rta_getattr_u8(tb[IFLA_GENEVE_TTL_INHERIT])) {
> print_string(PRINT_FP, NULL, "ttl %s ", "inherit");
> --
> 2.54.0.746.g67dd491aae-goog
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
2026-05-23 6:10 [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6 Kuniyuki Iwashima
2026-06-02 18:38 ` Kuniyuki Iwashima
@ 2026-06-02 19:59 ` Stephen Hemminger
2026-06-02 20:06 ` Kuniyuki Iwashima
1 sibling, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2026-06-02 19:59 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Kuniyuki Iwashima, netdev
On Sat, 23 May 2026 06:10:58 +0000
Kuniyuki Iwashima <kuniyu@google.com> wrote:
> + } else if (!matches(*argv, "local")) {
> + NEXT_ARG();
> + check_duparg(&attrs, IFLA_GENEVE_LOCAL, "local",
> + *argv);
> + get_addr(&saddr, *argv, AF_UNSPEC);
> + if (!is_addrtype_inet_not_multi(&saddr))
> + invarg("invalid local address", *argv);
No new code can use matches(), it creates problems with conflicting
short arguments.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
2026-06-02 19:59 ` Stephen Hemminger
@ 2026-06-02 20:06 ` Kuniyuki Iwashima
2026-06-02 20:26 ` Stephen Hemminger
0 siblings, 1 reply; 6+ messages in thread
From: Kuniyuki Iwashima @ 2026-06-02 20:06 UTC (permalink / raw)
To: Stephen Hemminger
Cc: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Kuniyuki Iwashima, netdev
On Tue, Jun 2, 2026 at 12:59 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Sat, 23 May 2026 06:10:58 +0000
> Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> > + } else if (!matches(*argv, "local")) {
> > + NEXT_ARG();
> > + check_duparg(&attrs, IFLA_GENEVE_LOCAL, "local",
> > + *argv);
> > + get_addr(&saddr, *argv, AF_UNSPEC);
> > + if (!is_addrtype_inet_not_multi(&saddr))
> > + invarg("invalid local address", *argv);
>
> No new code can use matches(), it creates problems with conflicting
> short arguments.
TIL, so the recommendation is simply using !strcmp(*argv, "local")
or anything else ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
2026-06-02 20:06 ` Kuniyuki Iwashima
@ 2026-06-02 20:26 ` Stephen Hemminger
2026-06-02 20:30 ` Kuniyuki Iwashima
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2026-06-02 20:26 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Kuniyuki Iwashima, netdev
On Tue, 2 Jun 2026 13:06:33 -0700
Kuniyuki Iwashima <kuniyu@google.com> wrote:
> > No new code can use matches(), it creates problems with conflicting
> > short arguments.
>
> TIL, so the recommendation is simply using !strcmp(*argv, "local")
> or anything else ?
Yes, that is preferred.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6.
2026-06-02 20:26 ` Stephen Hemminger
@ 2026-06-02 20:30 ` Kuniyuki Iwashima
0 siblings, 0 replies; 6+ messages in thread
From: Kuniyuki Iwashima @ 2026-06-02 20:30 UTC (permalink / raw)
To: Stephen Hemminger
Cc: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Kuniyuki Iwashima, netdev
On Tue, Jun 2, 2026 at 1:26 PM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> On Tue, 2 Jun 2026 13:06:33 -0700
> Kuniyuki Iwashima <kuniyu@google.com> wrote:
>
> > > No new code can use matches(), it creates problems with conflicting
> > > short arguments.
> >
> > TIL, so the recommendation is simply using !strcmp(*argv, "local")
> > or anything else ?
>
> Yes, that is preferred.
Thanks, will use it.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-02 20:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-23 6:10 [PATCH v1 iproute2-next] iplink_geneve: Support IFLA_GENEVE_LOCAL and IFLA_GENEVE_LOCAL6 Kuniyuki Iwashima
2026-06-02 18:38 ` Kuniyuki Iwashima
2026-06-02 19:59 ` Stephen Hemminger
2026-06-02 20:06 ` Kuniyuki Iwashima
2026-06-02 20:26 ` Stephen Hemminger
2026-06-02 20:30 ` Kuniyuki Iwashima
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox