mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
udp_tunnel: reshuffle NETIF_F_RX_UDP_TUNNEL_PORT checks
Move the NETIF_F_RX_UDP_TUNNEL_PORT feature check into udp_tunnel_nic_*_port() helpers, since they're always done right before the call. Add similar checks before calling the notifier. udp_tunnel_nic invokes the notifier without checking features which could result in some wasted cycles. Reviewed-by: Alexander Duyck <alexanderduyck@fb.com> Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
@@ -129,12 +129,16 @@ void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type);
|
|||||||
static inline void udp_tunnel_get_rx_info(struct net_device *dev)
|
static inline void udp_tunnel_get_rx_info(struct net_device *dev)
|
||||||
{
|
{
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
|
if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT))
|
||||||
|
return;
|
||||||
call_netdevice_notifiers(NETDEV_UDP_TUNNEL_PUSH_INFO, dev);
|
call_netdevice_notifiers(NETDEV_UDP_TUNNEL_PUSH_INFO, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void udp_tunnel_drop_rx_info(struct net_device *dev)
|
static inline void udp_tunnel_drop_rx_info(struct net_device *dev)
|
||||||
{
|
{
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
|
if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT))
|
||||||
|
return;
|
||||||
call_netdevice_notifiers(NETDEV_UDP_TUNNEL_DROP_INFO, dev);
|
call_netdevice_notifiers(NETDEV_UDP_TUNNEL_DROP_INFO, dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,6 +327,8 @@ udp_tunnel_nic_set_port_priv(struct net_device *dev, unsigned int table,
|
|||||||
static inline void
|
static inline void
|
||||||
udp_tunnel_nic_add_port(struct net_device *dev, struct udp_tunnel_info *ti)
|
udp_tunnel_nic_add_port(struct net_device *dev, struct udp_tunnel_info *ti)
|
||||||
{
|
{
|
||||||
|
if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT))
|
||||||
|
return;
|
||||||
if (udp_tunnel_nic_ops)
|
if (udp_tunnel_nic_ops)
|
||||||
udp_tunnel_nic_ops->add_port(dev, ti);
|
udp_tunnel_nic_ops->add_port(dev, ti);
|
||||||
}
|
}
|
||||||
@@ -330,6 +336,8 @@ udp_tunnel_nic_add_port(struct net_device *dev, struct udp_tunnel_info *ti)
|
|||||||
static inline void
|
static inline void
|
||||||
udp_tunnel_nic_del_port(struct net_device *dev, struct udp_tunnel_info *ti)
|
udp_tunnel_nic_del_port(struct net_device *dev, struct udp_tunnel_info *ti)
|
||||||
{
|
{
|
||||||
|
if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT))
|
||||||
|
return;
|
||||||
if (udp_tunnel_nic_ops)
|
if (udp_tunnel_nic_ops)
|
||||||
udp_tunnel_nic_ops->del_port(dev, ti);
|
udp_tunnel_nic_ops->del_port(dev, ti);
|
||||||
}
|
}
|
||||||
|
@@ -90,9 +90,6 @@ void udp_tunnel_push_rx_port(struct net_device *dev, struct socket *sock,
|
|||||||
struct sock *sk = sock->sk;
|
struct sock *sk = sock->sk;
|
||||||
struct udp_tunnel_info ti;
|
struct udp_tunnel_info ti;
|
||||||
|
|
||||||
if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ti.type = type;
|
ti.type = type;
|
||||||
ti.sa_family = sk->sk_family;
|
ti.sa_family = sk->sk_family;
|
||||||
ti.port = inet_sk(sk)->inet_sport;
|
ti.port = inet_sk(sk)->inet_sport;
|
||||||
@@ -107,9 +104,6 @@ void udp_tunnel_drop_rx_port(struct net_device *dev, struct socket *sock,
|
|||||||
struct sock *sk = sock->sk;
|
struct sock *sk = sock->sk;
|
||||||
struct udp_tunnel_info ti;
|
struct udp_tunnel_info ti;
|
||||||
|
|
||||||
if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT))
|
|
||||||
return;
|
|
||||||
|
|
||||||
ti.type = type;
|
ti.type = type;
|
||||||
ti.sa_family = sk->sk_family;
|
ti.sa_family = sk->sk_family;
|
||||||
ti.port = inet_sk(sk)->inet_sport;
|
ti.port = inet_sk(sk)->inet_sport;
|
||||||
@@ -132,8 +126,6 @@ void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type)
|
|||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
for_each_netdev_rcu(net, dev) {
|
for_each_netdev_rcu(net, dev) {
|
||||||
if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT))
|
|
||||||
continue;
|
|
||||||
udp_tunnel_nic_add_port(dev, &ti);
|
udp_tunnel_nic_add_port(dev, &ti);
|
||||||
}
|
}
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
@@ -154,8 +146,6 @@ void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type)
|
|||||||
|
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
for_each_netdev_rcu(net, dev) {
|
for_each_netdev_rcu(net, dev) {
|
||||||
if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT))
|
|
||||||
continue;
|
|
||||||
udp_tunnel_nic_del_port(dev, &ti);
|
udp_tunnel_nic_del_port(dev, &ti);
|
||||||
}
|
}
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
|
Reference in New Issue
Block a user