Skip to content

Commit 9c62a68

Browse files
ebiedermdavem330
authored andcommitted
netpoll: Remove dead packet receive code (CONFIG_NETPOLL_TRAP)
The netpoll packet receive code only becomes active if the netpoll rx_skb_hook is implemented, and there is not a single implementation of the netpoll rx_skb_hook in the kernel. All of the out of tree implementations I have found all call netpoll_poll which was removed from the kernel in 2011, so this change should not add any additional breakage. There are problems with the netpoll packet receive code. __netpoll_rx does not call dev_kfree_skb_irq or dev_kfree_skb_any in hard irq context. netpoll_neigh_reply leaks every skb it receives. Reception of packets does not work successfully on stacked devices (aka bonding, team, bridge, and vlans). Given that the netpoll packet receive code is buggy, there are no out of tree users that will be merged soon, and the code has not been used for in tree for a decade let's just remove it. Reverting this commit can server as a starting point for anyone who wants to resurrect netpoll packet reception support. Acked-by: Eric Dumazet <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e1bd4d3 commit 9c62a68

File tree

5 files changed

+2
-635
lines changed

5 files changed

+2
-635
lines changed

drivers/net/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,6 @@ config NETCONSOLE_DYNAMIC
177177
config NETPOLL
178178
def_bool NETCONSOLE
179179

180-
config NETPOLL_TRAP
181-
bool "Netpoll traffic trapping"
182-
default n
183-
depends on NETPOLL
184-
185180
config NET_POLL_CONTROLLER
186181
def_bool NETPOLL
187182

include/linux/netdevice.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,9 +1979,6 @@ struct net_device *__dev_get_by_index(struct net *net, int ifindex);
19791979
struct net_device *dev_get_by_index_rcu(struct net *net, int ifindex);
19801980
int netdev_get_name(struct net *net, char *name, int ifindex);
19811981
int dev_restart(struct net_device *dev);
1982-
#ifdef CONFIG_NETPOLL_TRAP
1983-
int netpoll_trap(void);
1984-
#endif
19851982
int skb_gro_receive(struct sk_buff **head, struct sk_buff *skb);
19861983

19871984
static inline unsigned int skb_gro_offset(const struct sk_buff *skb)
@@ -2186,12 +2183,6 @@ static inline void netif_tx_start_all_queues(struct net_device *dev)
21862183

21872184
static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)
21882185
{
2189-
#ifdef CONFIG_NETPOLL_TRAP
2190-
if (netpoll_trap()) {
2191-
netif_tx_start_queue(dev_queue);
2192-
return;
2193-
}
2194-
#endif
21952186
if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state))
21962187
__netif_schedule(dev_queue->qdisc);
21972188
}
@@ -2435,10 +2426,6 @@ static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index)
24352426
static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
24362427
{
24372428
struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
2438-
#ifdef CONFIG_NETPOLL_TRAP
2439-
if (netpoll_trap())
2440-
return;
2441-
#endif
24422429
netif_tx_stop_queue(txq);
24432430
}
24442431

@@ -2473,10 +2460,6 @@ static inline bool netif_subqueue_stopped(const struct net_device *dev,
24732460
static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index)
24742461
{
24752462
struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
2476-
#ifdef CONFIG_NETPOLL_TRAP
2477-
if (netpoll_trap())
2478-
return;
2479-
#endif
24802463
if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &txq->state))
24812464
__netif_schedule(txq->qdisc);
24822465
}

include/linux/netpoll.h

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ struct netpoll {
3131
u8 remote_mac[ETH_ALEN];
3232

3333
struct work_struct cleanup_work;
34-
35-
#ifdef CONFIG_NETPOLL_TRAP
36-
void (*rx_skb_hook)(struct netpoll *np, int source, struct sk_buff *skb,
37-
int offset, int len);
38-
struct list_head rx; /* rx_np list element */
39-
#endif
4034
};
4135

4236
struct netpoll_info {
@@ -50,12 +44,6 @@ struct netpoll_info {
5044

5145
struct netpoll *netpoll;
5246
struct rcu_head rcu;
53-
54-
#ifdef CONFIG_NETPOLL_TRAP
55-
spinlock_t rx_lock;
56-
struct list_head rx_np; /* netpolls that registered an rx_skb_hook */
57-
struct sk_buff_head neigh_tx; /* list of neigh requests to reply to */
58-
#endif
5947
};
6048

6149
#ifdef CONFIG_NETPOLL
@@ -84,78 +72,6 @@ static inline void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
8472
local_irq_restore(flags);
8573
}
8674

87-
#ifdef CONFIG_NETPOLL_TRAP
88-
int netpoll_trap(void);
89-
void netpoll_set_trap(int trap);
90-
int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo);
91-
static inline bool netpoll_rx_processing(struct netpoll_info *npinfo)
92-
{
93-
return !list_empty(&npinfo->rx_np);
94-
}
95-
96-
static inline bool netpoll_rx_on(struct sk_buff *skb)
97-
{
98-
struct netpoll_info *npinfo = rcu_dereference_bh(skb->dev->npinfo);
99-
100-
return npinfo && netpoll_rx_processing(npinfo);
101-
}
102-
103-
static inline bool netpoll_rx(struct sk_buff *skb)
104-
{
105-
struct netpoll_info *npinfo;
106-
unsigned long flags;
107-
bool ret = false;
108-
109-
local_irq_save(flags);
110-
111-
if (!netpoll_rx_on(skb))
112-
goto out;
113-
114-
npinfo = rcu_dereference_bh(skb->dev->npinfo);
115-
spin_lock(&npinfo->rx_lock);
116-
/* check rx_processing again with the lock held */
117-
if (netpoll_rx_processing(npinfo) && __netpoll_rx(skb, npinfo))
118-
ret = true;
119-
spin_unlock(&npinfo->rx_lock);
120-
121-
out:
122-
local_irq_restore(flags);
123-
return ret;
124-
}
125-
126-
static inline int netpoll_receive_skb(struct sk_buff *skb)
127-
{
128-
if (!list_empty(&skb->dev->napi_list))
129-
return netpoll_rx(skb);
130-
return 0;
131-
}
132-
133-
#else
134-
static inline int netpoll_trap(void)
135-
{
136-
return 0;
137-
}
138-
static inline void netpoll_set_trap(int trap)
139-
{
140-
}
141-
static inline bool netpoll_rx_processing(struct netpoll_info *npinfo)
142-
{
143-
return false;
144-
}
145-
static inline bool netpoll_rx(struct sk_buff *skb)
146-
{
147-
return false;
148-
}
149-
static inline bool netpoll_rx_on(struct sk_buff *skb)
150-
{
151-
return false;
152-
}
153-
static inline int netpoll_receive_skb(struct sk_buff *skb)
154-
{
155-
return 0;
156-
}
157-
#endif
158-
15975
#ifdef CONFIG_NETPOLL
16076
static inline void *netpoll_poll_lock(struct napi_struct *napi)
16177
{

net/core/dev.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3231,10 +3231,6 @@ static int netif_rx_internal(struct sk_buff *skb)
32313231
{
32323232
int ret;
32333233

3234-
/* if netpoll wants it, pretend we never saw it */
3235-
if (netpoll_rx(skb))
3236-
return NET_RX_DROP;
3237-
32383234
net_timestamp_check(netdev_tstamp_prequeue, skb);
32393235

32403236
trace_netif_rx(skb);
@@ -3520,10 +3516,6 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
35203516

35213517
trace_netif_receive_skb(skb);
35223518

3523-
/* if we've gotten here through NAPI, check netpoll */
3524-
if (netpoll_receive_skb(skb))
3525-
goto out;
3526-
35273519
orig_dev = skb->dev;
35283520

35293521
skb_reset_network_header(skb);
@@ -3650,7 +3642,6 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
36503642

36513643
unlock:
36523644
rcu_read_unlock();
3653-
out:
36543645
return ret;
36553646
}
36563647

@@ -3875,7 +3866,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
38753866
int same_flow;
38763867
enum gro_result ret;
38773868

3878-
if (!(skb->dev->features & NETIF_F_GRO) || netpoll_rx_on(skb))
3869+
if (!(skb->dev->features & NETIF_F_GRO))
38793870
goto normal;
38803871

38813872
if (skb_is_gso(skb) || skb_has_frag_list(skb))

0 commit comments

Comments
 (0)