From: Roopa Prabhu <roopa@cumulusnetworks.com>
To: abauvin@scaleway.com
Cc: David Ahern <dsa@cumulusnetworks.com>,
Stephen Hemminger <stephen@networkplumber.org>,
netdev <netdev@vger.kernel.org>,
akherbouche@scaleway.com
Subject: Re: [PATCH v5 5/6] vxlan: handle underlay VRF changes
Date: Mon, 26 Nov 2018 21:58:03 -0800 [thread overview]
Message-ID: <CAJieiUhFsA799SjSVaYPtpEajH5rAD907ObPXoZ4KYKjvxMeTg@mail.gmail.com> (raw)
In-Reply-To: <20181127010357.59070-6-abauvin@scaleway.com>
On Mon, Nov 26, 2018 at 5:04 PM Alexis Bauvin <abauvin@scaleway.com> wrote:
>
> When underlay VRF changes, either because the lower device itself changed,
> or its VRF changed, this patch releases the current socket of the VXLAN
> device and recreates another one in the right VRF. This allows for
> on-the-fly change of the underlay VRF of a VXLAN device.
>
> Signed-off-by: Alexis Bauvin <abauvin@scaleway.com>
> Reviewed-by: Amine Kherbouche <akherbouche@scaleway.com>
> Tested-by: Amine Kherbouche <akherbouche@scaleway.com>
> ---
re-iterating my comments on the patch this time.
this version still unconditionally calls reopen even if the current
state of the device is closed (eg vxlan_stop).
generally not in favor of the unconditional open/close in the driver.
Lets see if there are other options.
I interpreted one of Davids suggestions to force the change ordering
from user-space by returning an error.
ie Make the user do a down and up of the vxlan device if he wants to
change the vrf of the default remote dev.
This patch needs more thought, the rest are ok to go in if you
separate them out.
> drivers/net/vxlan.c | 82 +++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 82 insertions(+)
>
> diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
> index 8ba0a57ff958..131ee80a38f9 100644
> --- a/drivers/net/vxlan.c
> +++ b/drivers/net/vxlan.c
> @@ -3720,6 +3720,33 @@ struct net_device *vxlan_dev_create(struct net *net, const char *name,
> }
> EXPORT_SYMBOL_GPL(vxlan_dev_create);
>
> +static int vxlan_reopen(struct vxlan_net *vn, struct vxlan_dev *vxlan)
> +{
> + int ret = 0;
> +
> + if (vxlan_addr_multicast(&vxlan->default_dst.remote_ip) &&
> + !vxlan_group_used(vn, vxlan))
> + ret = vxlan_igmp_leave(vxlan);
> + vxlan_sock_release(vxlan);
> +
> + if (ret < 0)
> + return ret;
> +
> + ret = vxlan_sock_add(vxlan);
> + if (ret < 0)
> + return ret;
> +
> + if (vxlan_addr_multicast(&vxlan->default_dst.remote_ip)) {
> + ret = vxlan_igmp_join(vxlan);
> + if (ret == -EADDRINUSE)
> + ret = 0;
> + if (ret)
> + vxlan_sock_release(vxlan);
> + }
> +
> + return ret;
> +}
> +
> static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn,
> struct net_device *dev)
> {
> @@ -3742,6 +3769,55 @@ static void vxlan_handle_lowerdev_unregister(struct vxlan_net *vn,
> unregister_netdevice_many(&list_kill);
> }
>
> +static void vxlan_handle_change_upper(struct vxlan_net *vn,
> + struct net_device *dev)
> +{
> + struct vxlan_dev *vxlan, *next;
> +
> + list_for_each_entry_safe(vxlan, next, &vn->vxlan_list, next) {
> + struct net_device *lower;
> + int err;
> +
> + lower = __dev_get_by_index(vxlan->net,
> + vxlan->cfg.remote_ifindex);
> + if (!netdev_is_upper_master(lower, dev))
> + continue;
> +
> + err = vxlan_reopen(vn, vxlan);
> + if (err < 0)
> + netdev_err(vxlan->dev, "Failed to reopen socket: %d\n",
> + err);
> + }
> +}
> +
> +static void vxlan_handle_change(struct vxlan_net *vn, struct net_device *dev)
> +{
> + struct vxlan_dev *vxlan = netdev_priv(dev);
> + struct vxlan_sock *sock;
> + int l3mdev_index = 0;
> +
> +#if IS_ENABLED(CONFIG_IPV6)
> + bool metadata = vxlan->cfg.flags & VXLAN_F_COLLECT_METADATA;
> + bool ipv6 = vxlan->cfg.flags & VXLAN_F_IPV6 || metadata;
> +
> + sock = ipv6 ? rcu_dereference(vxlan->vn6_sock)
> + : rcu_dereference(vxlan->vn4_sock);
> +#else
> + sock = rcu_dereference(vxlan->vn4_sock);
> +#endif
> +
> + if (vxlan->cfg.remote_ifindex)
> + l3mdev_index = l3mdev_master_upper_ifindex_by_index(
> + vxlan->net, vxlan->cfg.remote_ifindex);
> + if (sock->sock->sk->sk_bound_dev_if != l3mdev_index) {
> + int ret = vxlan_reopen(vn, vxlan);
> +
> + if (ret < 0)
> + netdev_err(vxlan->dev, "Failed to reopen socket: %d\n",
> + ret);
> + }
> +}
> +
> static int vxlan_netdevice_event(struct notifier_block *unused,
> unsigned long event, void *ptr)
> {
> @@ -3756,6 +3832,12 @@ static int vxlan_netdevice_event(struct notifier_block *unused,
> } else if (event == NETDEV_UDP_TUNNEL_PUSH_INFO ||
> event == NETDEV_UDP_TUNNEL_DROP_INFO) {
> vxlan_offload_rx_ports(dev, event == NETDEV_UDP_TUNNEL_PUSH_INFO);
> + } else if (event == NETDEV_CHANGEUPPER) {
> + vxlan_handle_change_upper(vn, dev);
> + } else if (event == NETDEV_CHANGE) {
> + if (dev->rtnl_link_ops &&
> + !strcmp(dev->rtnl_link_ops->kind, vxlan_link_ops.kind))
> + vxlan_handle_change(vn, dev);
This should move to the rtnl changelink handler
> }
>
> return NOTIFY_DONE;
> --
>
next prev parent reply other threads:[~2018-11-27 16:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-27 1:03 [PATCH v5 0/6] Add VRF support for VXLAN underlay Alexis Bauvin
2018-11-27 1:03 ` [PATCH v5 1/6] udp_tunnel: add config option to bind to a device Alexis Bauvin
2018-11-27 1:03 ` [PATCH v5 2/6] l3mdev: add function to retreive upper master Alexis Bauvin
2018-11-27 1:03 ` [PATCH v5 3/6] vxlan: add support for underlay in non-default VRF Alexis Bauvin
2018-11-27 1:03 ` [PATCH v5 4/6] netdev: add netdev_is_upper_master Alexis Bauvin
2018-11-27 1:03 ` [PATCH v5 5/6] vxlan: handle underlay VRF changes Alexis Bauvin
2018-11-27 5:58 ` Roopa Prabhu [this message]
2018-11-27 12:55 ` Alexis Bauvin
2018-11-27 1:03 ` [PATCH v5 6/6] test/net: Add script for VXLAN underlay in a VRF Alexis Bauvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJieiUhFsA799SjSVaYPtpEajH5rAD907ObPXoZ4KYKjvxMeTg@mail.gmail.com \
--to=roopa@cumulusnetworks.com \
--cc=abauvin@scaleway.com \
--cc=akherbouche@scaleway.com \
--cc=dsa@cumulusnetworks.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).