Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[cascardo/linux.git] / net / ipv4 / udp_tunnel.c
index 47f12c7..58bd39f 100644 (file)
@@ -76,6 +76,67 @@ void setup_udp_tunnel_sock(struct net *net, struct socket *sock,
 }
 EXPORT_SYMBOL_GPL(setup_udp_tunnel_sock);
 
+void udp_tunnel_push_rx_port(struct net_device *dev, struct socket *sock,
+                            unsigned short type)
+{
+       struct sock *sk = sock->sk;
+       struct udp_tunnel_info ti;
+
+       if (!dev->netdev_ops->ndo_udp_tunnel_add)
+               return;
+
+       ti.type = type;
+       ti.sa_family = sk->sk_family;
+       ti.port = inet_sk(sk)->inet_sport;
+
+       dev->netdev_ops->ndo_udp_tunnel_add(dev, &ti);
+}
+EXPORT_SYMBOL_GPL(udp_tunnel_push_rx_port);
+
+/* Notify netdevs that UDP port started listening */
+void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type)
+{
+       struct sock *sk = sock->sk;
+       struct net *net = sock_net(sk);
+       struct udp_tunnel_info ti;
+       struct net_device *dev;
+
+       ti.type = type;
+       ti.sa_family = sk->sk_family;
+       ti.port = inet_sk(sk)->inet_sport;
+
+       rcu_read_lock();
+       for_each_netdev_rcu(net, dev) {
+               if (!dev->netdev_ops->ndo_udp_tunnel_add)
+                       continue;
+               dev->netdev_ops->ndo_udp_tunnel_add(dev, &ti);
+       }
+       rcu_read_unlock();
+}
+EXPORT_SYMBOL_GPL(udp_tunnel_notify_add_rx_port);
+
+/* Notify netdevs that UDP port is no more listening */
+void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type)
+{
+       struct sock *sk = sock->sk;
+       struct net *net = sock_net(sk);
+       struct udp_tunnel_info ti;
+       struct net_device *dev;
+
+       ti.type = type;
+       ti.sa_family = sk->sk_family;
+       ti.port = inet_sk(sk)->inet_sport;
+
+       rcu_read_lock();
+       for_each_netdev_rcu(net, dev) {
+               if (!dev->netdev_ops->ndo_udp_tunnel_del)
+                       continue;
+               dev->netdev_ops->ndo_udp_tunnel_del(dev, &ti);
+       }
+       rcu_read_unlock();
+}
+EXPORT_SYMBOL_GPL(udp_tunnel_notify_del_rx_port);
+
 void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb,
                         __be32 src, __be32 dst, __u8 tos, __u8 ttl,
                         __be16 df, __be16 src_port, __be16 dst_port,