From: John Fastabend <john.r.fastabend@intel.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: davem@davemloft.net,
Joseph Gasparakis <joseph.gasparakis@intel.com>,
netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com,
Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [net-next 1/2] vxlan: Notify drivers for listening UDP port changes
Date: Wed, 28 Aug 2013 12:34:09 -0700 [thread overview]
Message-ID: <521E50B1.4010102@intel.com> (raw)
In-Reply-To: <1377665218-6760-1-git-send-email-jeffrey.t.kirsher@intel.com>
On 8/27/2013 9:46 PM, Jeff Kirsher wrote:
> From: Joseph Gasparakis <joseph.gasparakis@intel.com>
>
> This patch adds two more ndo ops: ndo_add_rx_vxlan_port() and
> ndo_del_rx_vxlan_port().
>
> Drivers can get notifications through the above functions about changes
> of the UDP listening port of VXLAN. Also, when physical ports come up,
> now they can call vxlan_get_rx_port() in order to obtain the port number(s)
> of the existing VXLAN interface in case they already up before them.
>
> This information about the listening UDP port would be used for VXLAN
> related offloads.
[...]
> /* Add new entry to forwarding table -- assumes lock held */
> static int vxlan_fdb_create(struct vxlan_dev *vxlan,
> const u8 *mac, __be32 ip,
> @@ -797,13 +823,15 @@ static void vxlan_sock_hold(struct vxlan_sock *vs)
>
> void vxlan_sock_release(struct vxlan_sock *vs)
> {
> - struct vxlan_net *vn = net_generic(sock_net(vs->sock->sk), vxlan_net_id);
> + struct net *net = sock_net(vs->sock->sk);
> + struct vxlan_net *vn = net_generic(net, vxlan_net_id);
>
> if (!atomic_dec_and_test(&vs->refcnt))
> return;
>
> spin_lock(&vn->sock_lock);
> hlist_del_rcu(&vs->hlist);
> + vxlan_notify_del_rx_port(net, inet_sk(vs->sock->sk)->inet_sport);
> spin_unlock(&vn->sock_lock);
Both the del and add port are protected by sock_lock serializing the
operations.
>
> queue_work(vxlan_wq, &vs->del_work);
> @@ -1543,6 +1571,28 @@ static struct device_type vxlan_type = {
> .name = "vxlan",
> };
>
> +/* Calls the ndo_add_vxlan_port of the caller in order to
> + * supply the listening VXLAN udp ports.
> + */
> +void vxlan_get_rx_port(struct net_device *dev)
> +{
> + struct vxlan_sock *vs;
> + struct net *net = dev_net(dev);
> + u16 port;
> + int i;
> +
> + if (!dev || !dev->netdev_ops || !dev->netdev_ops->ndo_add_vxlan_port)
> + return;
> +
> + for (i = 0; i < PORT_HASH_SIZE; ++i) {
> + hlist_for_each_entry_rcu(vs, vs_head(net, i), hlist) {
> + port = htons(inet_sk(vs->sock->sk)->inet_sport);
> + dev->netdev_ops->ndo_add_vxlan_port(dev, port);
However this list walk occurs without the sock_lock. Looks like you
could delete a port and then subsequently add it here if you had really
"good" timing.
Then it would be deleted from the vxlan list but pushed into hardware.
Probably not a terrible scenario but it would waste hardware resources.
I suspect you want to lock this list traversal with the sock_lock as
well.
> + }
> + }
> +}
> +EXPORT_SYMBOL_GPL(vxlan_get_rx_port);
next prev parent reply other threads:[~2013-08-28 19:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-28 4:46 [net-next 1/2] vxlan: Notify drivers for listening UDP port changes Jeff Kirsher
2013-08-28 4:46 ` [net-next 2/2] ixgbe: Get and display the notifications from changes of the Rx vxlan UDP port Jeff Kirsher
2013-08-28 4:53 ` Jeff Kirsher
2013-08-28 7:47 ` [net-next 1/2] vxlan: Notify drivers for listening UDP port changes Cong Wang
2013-08-28 11:43 ` Ben Hutchings
2013-08-28 19:34 ` John Fastabend [this message]
2013-08-28 20:41 ` Joseph Gasparakis
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=521E50B1.4010102@intel.com \
--to=john.r.fastabend@intel.com \
--cc=davem@davemloft.net \
--cc=gospo@redhat.com \
--cc=jeffrey.t.kirsher@intel.com \
--cc=joseph.gasparakis@intel.com \
--cc=netdev@vger.kernel.org \
--cc=sassmann@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.