]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
geneve: Add geneve_get_rx_port support
authorSinghai, Anjali <anjali.singhai@intel.com>
Mon, 14 Dec 2015 20:21:20 +0000 (12:21 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Dec 2015 15:58:56 +0000 (10:58 -0500)
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>
drivers/net/geneve.c
include/net/geneve.h

index 89325e483ecfc296e8a4a7d872bee1006ebb8bcc..31b19fdf659d45d16ea5e7afb3836b86e70a1640 100644 (file)
@@ -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)
 {
index 3106ed6eae0d1b908544e5aa044df3704fd2c46a..e6c23dc765f7ecae795e9c6acb72b5ac017e04f7 100644 (file)
@@ -62,6 +62,14 @@ struct genevehdr {
        struct geneve_opt options[];
 };
 
+#if IS_ENABLED(CONFIG_GENEVE)
+void geneve_get_rx_port(struct net_device *netdev);
+#else
+static inline void geneve_get_rx_port(struct net_device *netdev)
+{
+}
+#endif
+
 #ifdef CONFIG_INET
 struct net_device *geneve_dev_create_fb(struct net *net, const char *name,
                                        u8 name_assign_type, u16 dst_port);