aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/geneve.c
diff options
context:
space:
mode:
authorSinghai, Anjali2015-12-14 12:21:20 -0800
committerDavid S. Miller2015-12-16 10:58:56 -0500
commit05ca4029b25c65c860be5baa9288ec8f7e0a97e6 (patch)
treeff21869a2c818b772ce7e2f9e5339168ebaad00f /drivers/net/geneve.c
parentc110c311b195c54ce75bc2e85bbebd88d566d86c (diff)
geneve: Add geneve_get_rx_port support
This patch adds an op that the drivers can call into to get existing geneve ports. Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/geneve.c')
-rw-r--r--drivers/net/geneve.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index 89325e483ecf..31b19fdf659d 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1109,6 +1109,30 @@ static struct device_type geneve_type = {
.name = "geneve",
};
+/* Calls the ndo_add_geneve_port of the caller in order to
+ * supply the listening GENEVE udp ports. Callers are expected
+ * to implement the ndo_add_geneve_port.
+ */
+void geneve_get_rx_port(struct net_device *dev)
+{
+ struct net *net = dev_net(dev);
+ struct geneve_net *gn = net_generic(net, geneve_net_id);
+ struct geneve_sock *gs;
+ sa_family_t sa_family;
+ struct sock *sk;
+ __be16 port;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(gs, &gn->sock_list, list) {
+ sk = gs->sock->sk;
+ sa_family = sk->sk_family;
+ port = inet_sk(sk)->inet_sport;
+ dev->netdev_ops->ndo_add_geneve_port(dev, sa_family, port);
+ }
+ rcu_read_unlock();
+}
+EXPORT_SYMBOL_GPL(geneve_get_rx_port);
+
/* Initialize the device structure. */
static void geneve_setup(struct net_device *dev)
{