@@ -254,6 +254,18 @@ void ipvlan_process_multicast(struct work_struct *work)
254
254
}
255
255
}
256
256
257
+ static void ipvlan_skb_crossing_ns (struct sk_buff * skb , struct net_device * dev )
258
+ {
259
+ bool xnet = true;
260
+
261
+ if (dev )
262
+ xnet = !net_eq (dev_net (skb -> dev ), dev_net (dev ));
263
+
264
+ skb_scrub_packet (skb , xnet );
265
+ if (dev )
266
+ skb -> dev = dev ;
267
+ }
268
+
257
269
static int ipvlan_rcv_frame (struct ipvl_addr * addr , struct sk_buff * * pskb ,
258
270
bool local )
259
271
{
@@ -280,7 +292,7 @@ static int ipvlan_rcv_frame(struct ipvl_addr *addr, struct sk_buff **pskb,
280
292
281
293
* pskb = skb ;
282
294
}
283
- skb -> dev = dev ;
295
+ ipvlan_skb_crossing_ns ( skb , dev ) ;
284
296
285
297
if (local ) {
286
298
skb -> pkt_type = PACKET_HOST ;
@@ -347,7 +359,7 @@ static struct ipvl_addr *ipvlan_addr_lookup(struct ipvl_port *port,
347
359
return addr ;
348
360
}
349
361
350
- static int ipvlan_process_v4_outbound (struct sk_buff * skb , bool xnet )
362
+ static int ipvlan_process_v4_outbound (struct sk_buff * skb )
351
363
{
352
364
const struct iphdr * ip4h = ip_hdr (skb );
353
365
struct net_device * dev = skb -> dev ;
@@ -370,7 +382,6 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb, bool xnet)
370
382
ip_rt_put (rt );
371
383
goto err ;
372
384
}
373
- skb_scrub_packet (skb , xnet );
374
385
skb_dst_set (skb , & rt -> dst );
375
386
err = ip_local_out (net , skb -> sk , skb );
376
387
if (unlikely (net_xmit_eval (err )))
@@ -385,7 +396,7 @@ static int ipvlan_process_v4_outbound(struct sk_buff *skb, bool xnet)
385
396
return ret ;
386
397
}
387
398
388
- static int ipvlan_process_v6_outbound (struct sk_buff * skb , bool xnet )
399
+ static int ipvlan_process_v6_outbound (struct sk_buff * skb )
389
400
{
390
401
const struct ipv6hdr * ip6h = ipv6_hdr (skb );
391
402
struct net_device * dev = skb -> dev ;
@@ -408,7 +419,6 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb, bool xnet)
408
419
dst_release (dst );
409
420
goto err ;
410
421
}
411
- skb_scrub_packet (skb , xnet );
412
422
skb_dst_set (skb , dst );
413
423
err = ip6_local_out (net , skb -> sk , skb );
414
424
if (unlikely (net_xmit_eval (err )))
@@ -423,7 +433,7 @@ static int ipvlan_process_v6_outbound(struct sk_buff *skb, bool xnet)
423
433
return ret ;
424
434
}
425
435
426
- static int ipvlan_process_outbound (struct sk_buff * skb , bool xnet )
436
+ static int ipvlan_process_outbound (struct sk_buff * skb )
427
437
{
428
438
struct ethhdr * ethh = eth_hdr (skb );
429
439
int ret = NET_XMIT_DROP ;
@@ -447,9 +457,9 @@ static int ipvlan_process_outbound(struct sk_buff *skb, bool xnet)
447
457
}
448
458
449
459
if (skb -> protocol == htons (ETH_P_IPV6 ))
450
- ret = ipvlan_process_v6_outbound (skb , xnet );
460
+ ret = ipvlan_process_v6_outbound (skb );
451
461
else if (skb -> protocol == htons (ETH_P_IP ))
452
- ret = ipvlan_process_v4_outbound (skb , xnet );
462
+ ret = ipvlan_process_v4_outbound (skb );
453
463
else {
454
464
pr_warn_ratelimited ("Dropped outbound packet type=%x\n" ,
455
465
ntohs (skb -> protocol ));
@@ -485,7 +495,6 @@ static int ipvlan_xmit_mode_l3(struct sk_buff *skb, struct net_device *dev)
485
495
void * lyr3h ;
486
496
struct ipvl_addr * addr ;
487
497
int addr_type ;
488
- bool xnet ;
489
498
490
499
lyr3h = ipvlan_get_L3_hdr (skb , & addr_type );
491
500
if (!lyr3h )
@@ -496,9 +505,8 @@ static int ipvlan_xmit_mode_l3(struct sk_buff *skb, struct net_device *dev)
496
505
return ipvlan_rcv_frame (addr , & skb , true);
497
506
498
507
out :
499
- xnet = !net_eq (dev_net (skb -> dev ), dev_net (ipvlan -> phy_dev ));
500
- skb -> dev = ipvlan -> phy_dev ;
501
- return ipvlan_process_outbound (skb , xnet );
508
+ ipvlan_skb_crossing_ns (skb , ipvlan -> phy_dev );
509
+ return ipvlan_process_outbound (skb );
502
510
}
503
511
504
512
static int ipvlan_xmit_mode_l2 (struct sk_buff * skb , struct net_device * dev )
@@ -528,11 +536,12 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev)
528
536
return dev_forward_skb (ipvlan -> phy_dev , skb );
529
537
530
538
} else if (is_multicast_ether_addr (eth -> h_dest )) {
539
+ ipvlan_skb_crossing_ns (skb , NULL );
531
540
ipvlan_multicast_enqueue (ipvlan -> port , skb );
532
541
return NET_XMIT_SUCCESS ;
533
542
}
534
543
535
- skb -> dev = ipvlan -> phy_dev ;
544
+ ipvlan_skb_crossing_ns ( skb , ipvlan -> phy_dev ) ;
536
545
return dev_queue_xmit (skb );
537
546
}
538
547
@@ -622,8 +631,10 @@ static rx_handler_result_t ipvlan_handle_mode_l2(struct sk_buff **pskb,
622
631
* when work-queue processes this frame. This is
623
632
* achieved by returning RX_HANDLER_PASS.
624
633
*/
625
- if (nskb )
634
+ if (nskb ) {
635
+ ipvlan_skb_crossing_ns (nskb , NULL );
626
636
ipvlan_multicast_enqueue (port , nskb );
637
+ }
627
638
}
628
639
} else {
629
640
struct ipvl_addr * addr ;
0 commit comments