@@ -48,6 +48,7 @@ static struct sk_buff_head skb_pool;
48
48
49
49
#ifdef CONFIG_NETPOLL_TRAP
50
50
static atomic_t trapped ;
51
+ static void netpoll_neigh_reply (struct sk_buff * skb , struct netpoll_info * npinfo );
51
52
#endif
52
53
53
54
DEFINE_STATIC_SRCU (netpoll_srcu );
@@ -61,7 +62,6 @@ DEFINE_STATIC_SRCU(netpoll_srcu);
61
62
MAX_UDP_CHUNK)
62
63
63
64
static void zap_completion_queue (void );
64
- static void netpoll_neigh_reply (struct sk_buff * skb , struct netpoll_info * npinfo );
65
65
static void netpoll_async_cleanup (struct work_struct * work );
66
66
67
67
static unsigned int carrier_timeout = 4 ;
@@ -109,6 +109,7 @@ static void queue_process(struct work_struct *work)
109
109
}
110
110
}
111
111
112
+ #ifdef CONFIG_NETPOLL_TRAP
112
113
static __sum16 checksum_udp (struct sk_buff * skb , struct udphdr * uh ,
113
114
unsigned short ulen , __be32 saddr , __be32 daddr )
114
115
{
@@ -127,6 +128,7 @@ static __sum16 checksum_udp(struct sk_buff *skb, struct udphdr *uh,
127
128
128
129
return __skb_checksum_complete (skb );
129
130
}
131
+ #endif /* CONFIG_NETPOLL_TRAP */
130
132
131
133
/*
132
134
* Check whether delayed processing was scheduled for our NIC. If so,
@@ -179,6 +181,7 @@ static void poll_napi(struct net_device *dev, int budget)
179
181
}
180
182
}
181
183
184
+ #ifdef CONFIG_NETPOLL_TRAP
182
185
static void service_neigh_queue (struct net_device * dev ,
183
186
struct netpoll_info * npi )
184
187
{
@@ -197,6 +200,12 @@ static void service_neigh_queue(struct net_device *dev,
197
200
while ((skb = skb_dequeue (& npi -> neigh_tx )))
198
201
netpoll_neigh_reply (skb , npi );
199
202
}
203
+ #else /* !CONFIG_NETPOLL_TRAP */
204
+ static inline void service_neigh_queue (struct net_device * dev ,
205
+ struct netpoll_info * npi )
206
+ {
207
+ }
208
+ #endif /* CONFIG_NETPOLL_TRAP */
200
209
201
210
static void netpoll_poll_dev (struct net_device * dev )
202
211
{
@@ -522,6 +531,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
522
531
}
523
532
EXPORT_SYMBOL (netpoll_send_udp );
524
533
534
+ #ifdef CONFIG_NETPOLL_TRAP
525
535
static void netpoll_neigh_reply (struct sk_buff * skb , struct netpoll_info * npinfo )
526
536
{
527
537
int size , type = ARPOP_REPLY ;
@@ -900,6 +910,55 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
900
910
return 0 ;
901
911
}
902
912
913
+ static void netpoll_trap_setup_info (struct netpoll_info * npinfo )
914
+ {
915
+ INIT_LIST_HEAD (& npinfo -> rx_np );
916
+ spin_lock_init (& npinfo -> rx_lock );
917
+ skb_queue_head_init (& npinfo -> neigh_tx );
918
+ }
919
+
920
+ static void netpoll_trap_cleanup_info (struct netpoll_info * npinfo )
921
+ {
922
+ skb_queue_purge (& npinfo -> neigh_tx );
923
+ }
924
+
925
+ static void netpoll_trap_setup (struct netpoll * np , struct netpoll_info * npinfo )
926
+ {
927
+ unsigned long flags ;
928
+ if (np -> rx_skb_hook ) {
929
+ spin_lock_irqsave (& npinfo -> rx_lock , flags );
930
+ list_add_tail (& np -> rx , & npinfo -> rx_np );
931
+ spin_unlock_irqrestore (& npinfo -> rx_lock , flags );
932
+ }
933
+ }
934
+
935
+ static void netpoll_trap_cleanup (struct netpoll * np , struct netpoll_info * npinfo )
936
+ {
937
+ unsigned long flags ;
938
+ if (!list_empty (& npinfo -> rx_np )) {
939
+ spin_lock_irqsave (& npinfo -> rx_lock , flags );
940
+ list_del (& np -> rx );
941
+ spin_unlock_irqrestore (& npinfo -> rx_lock , flags );
942
+ }
943
+ }
944
+
945
+ #else /* !CONFIG_NETPOLL_TRAP */
946
+ static inline void netpoll_trap_setup_info (struct netpoll_info * npinfo )
947
+ {
948
+ }
949
+ static inline void netpoll_trap_cleanup_info (struct netpoll_info * npinfo )
950
+ {
951
+ }
952
+ static inline
953
+ void netpoll_trap_setup (struct netpoll * np , struct netpoll_info * npinfo )
954
+ {
955
+ }
956
+ static inline
957
+ void netpoll_trap_cleanup (struct netpoll * np , struct netpoll_info * npinfo )
958
+ {
959
+ }
960
+ #endif /* CONFIG_NETPOLL_TRAP */
961
+
903
962
void netpoll_print_options (struct netpoll * np )
904
963
{
905
964
np_info (np , "local port %d\n" , np -> local_port );
@@ -1023,7 +1082,6 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp)
1023
1082
{
1024
1083
struct netpoll_info * npinfo ;
1025
1084
const struct net_device_ops * ops ;
1026
- unsigned long flags ;
1027
1085
int err ;
1028
1086
1029
1087
np -> dev = ndev ;
@@ -1045,11 +1103,9 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp)
1045
1103
goto out ;
1046
1104
}
1047
1105
1048
- INIT_LIST_HEAD ( & npinfo -> rx_np );
1106
+ netpoll_trap_setup_info ( npinfo );
1049
1107
1050
- spin_lock_init (& npinfo -> rx_lock );
1051
1108
sema_init (& npinfo -> dev_lock , 1 );
1052
- skb_queue_head_init (& npinfo -> neigh_tx );
1053
1109
skb_queue_head_init (& npinfo -> txq );
1054
1110
INIT_DELAYED_WORK (& npinfo -> tx_work , queue_process );
1055
1111
@@ -1068,11 +1124,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp)
1068
1124
1069
1125
npinfo -> netpoll = np ;
1070
1126
1071
- if (np -> rx_skb_hook ) {
1072
- spin_lock_irqsave (& npinfo -> rx_lock , flags );
1073
- list_add_tail (& np -> rx , & npinfo -> rx_np );
1074
- spin_unlock_irqrestore (& npinfo -> rx_lock , flags );
1075
- }
1127
+ netpoll_trap_setup (np , npinfo );
1076
1128
1077
1129
/* last thing to do is link it to the net device structure */
1078
1130
rcu_assign_pointer (ndev -> npinfo , npinfo );
@@ -1222,7 +1274,7 @@ static void rcu_cleanup_netpoll_info(struct rcu_head *rcu_head)
1222
1274
struct netpoll_info * npinfo =
1223
1275
container_of (rcu_head , struct netpoll_info , rcu );
1224
1276
1225
- skb_queue_purge ( & npinfo -> neigh_tx );
1277
+ netpoll_trap_cleanup_info ( npinfo );
1226
1278
skb_queue_purge (& npinfo -> txq );
1227
1279
1228
1280
/* we can't call cancel_delayed_work_sync here, as we are in softirq */
@@ -1238,7 +1290,6 @@ static void rcu_cleanup_netpoll_info(struct rcu_head *rcu_head)
1238
1290
void __netpoll_cleanup (struct netpoll * np )
1239
1291
{
1240
1292
struct netpoll_info * npinfo ;
1241
- unsigned long flags ;
1242
1293
1243
1294
/* rtnl_dereference would be preferable here but
1244
1295
* rcu_cleanup_netpoll path can put us in here safely without
@@ -1248,11 +1299,7 @@ void __netpoll_cleanup(struct netpoll *np)
1248
1299
if (!npinfo )
1249
1300
return ;
1250
1301
1251
- if (!list_empty (& npinfo -> rx_np )) {
1252
- spin_lock_irqsave (& npinfo -> rx_lock , flags );
1253
- list_del (& np -> rx );
1254
- spin_unlock_irqrestore (& npinfo -> rx_lock , flags );
1255
- }
1302
+ netpoll_trap_cleanup (np , npinfo );
1256
1303
1257
1304
synchronize_srcu (& netpoll_srcu );
1258
1305
0 commit comments