Re: [PATCH net-next v5 2/5] net: vxlan: add netlink option to bind vxlan sockets to local addresses

From: Ido Schimmel
Date: Wed Aug 13 2025 - 12:20:52 EST


On Wed, Aug 13, 2025 at 05:46:44PM +0200, Richard Gobert wrote:
> Kuniyuki Iwashima wrote:
> > From: Richard Gobert <richardbgobert@xxxxxxxxx>
> >> @@ -4044,15 +4045,37 @@ static int vxlan_nl2conf(struct nlattr *tb[], struct nlattr *data[],
> >> conf->vni = vni;
> >> }
> >>
> >> + if (data[IFLA_VXLAN_LOCALBIND]) {
> >> + if (changelink) {
> >> + NL_SET_ERR_MSG_ATTR(extack, tb[IFLA_VXLAN_LOCALBIND], "Cannot rebind locally");
> >> + return -EOPNOTSUPP;
> >> + }
> >
> > Are these two "if" necessary ?
>
> Creating a vxlan interface without localbind then adding localbind won't
> result in the socket being rebound. I might implement this in the future,
> but for simplicity, I didn't implement this yet.

I think Kuniyuki meant that you can just call vxlan_nl2flag() without
those two "if"s because the function is a NO-OP when the attribute is
not present and it will also fail the changelink operation.

>
> >
> >
> >> +
> >> + err = vxlan_nl2flag(conf, data, IFLA_VXLAN_LOCALBIND,
> >> + VXLAN_F_LOCALBIND, changelink,
> >> + false, extack);
> >> + if (err)
> >> + return err;
> >> + }
> >> +