8383int sysctl_ip_default_ttl __read_mostly = IPDEFTTL ;
8484EXPORT_SYMBOL (sysctl_ip_default_ttl );
8585
86- static int ip_fragment (struct sock * sk , struct sk_buff * skb ,
87- unsigned int mtu ,
88- int (* output )(struct sock * , struct sk_buff * ));
86+ static int
87+ ip_fragment (struct net * net , struct sock * sk , struct sk_buff * skb ,
88+ unsigned int mtu ,
89+ int (* output )(struct net * , struct sock * , struct sk_buff * ));
8990
9091/* Generate a checksum for an outgoing IP datagram. */
9192void ip_send_check (struct iphdr * iph )
@@ -176,12 +177,11 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
176177}
177178EXPORT_SYMBOL_GPL (ip_build_and_send_pkt );
178179
179- static int ip_finish_output2 (struct sock * sk , struct sk_buff * skb )
180+ static int ip_finish_output2 (struct net * net , struct sock * sk , struct sk_buff * skb )
180181{
181182 struct dst_entry * dst = skb_dst (skb );
182183 struct rtable * rt = (struct rtable * )dst ;
183184 struct net_device * dev = dst -> dev ;
184- struct net * net = dev_net (dev );
185185 unsigned int hh_len = LL_RESERVED_SPACE (dev );
186186 struct neighbour * neigh ;
187187 u32 nexthop ;
@@ -225,8 +225,8 @@ static int ip_finish_output2(struct sock *sk, struct sk_buff *skb)
225225 return - EINVAL ;
226226}
227227
228- static int ip_finish_output_gso (struct sock * sk , struct sk_buff * skb ,
229- unsigned int mtu )
228+ static int ip_finish_output_gso (struct net * net , struct sock * sk ,
229+ struct sk_buff * skb , unsigned int mtu )
230230{
231231 netdev_features_t features ;
232232 struct sk_buff * segs ;
@@ -235,7 +235,7 @@ static int ip_finish_output_gso(struct sock *sk, struct sk_buff *skb,
235235 /* common case: locally created skb or seglen is <= mtu */
236236 if (((IPCB (skb )-> flags & IPSKB_FORWARDED ) == 0 ) ||
237237 skb_gso_network_seglen (skb ) <= mtu )
238- return ip_finish_output2 (sk , skb );
238+ return ip_finish_output2 (net , sk , skb );
239239
240240 /* Slowpath - GSO segment length is exceeding the dst MTU.
241241 *
@@ -258,7 +258,7 @@ static int ip_finish_output_gso(struct sock *sk, struct sk_buff *skb,
258258 int err ;
259259
260260 segs -> next = NULL ;
261- err = ip_fragment (sk , segs , mtu , ip_finish_output2 );
261+ err = ip_fragment (net , sk , segs , mtu , ip_finish_output2 );
262262
263263 if (err && ret == 0 )
264264 ret = err ;
@@ -281,12 +281,12 @@ static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *sk
281281#endif
282282 mtu = ip_skb_dst_mtu (skb );
283283 if (skb_is_gso (skb ))
284- return ip_finish_output_gso (sk , skb , mtu );
284+ return ip_finish_output_gso (net , sk , skb , mtu );
285285
286286 if (skb -> len > mtu || (IPCB (skb )-> flags & IPSKB_FRAG_PMTU ))
287- return ip_fragment (sk , skb , mtu , ip_finish_output2 );
287+ return ip_fragment (net , sk , skb , mtu , ip_finish_output2 );
288288
289- return ip_finish_output2 (sk , skb );
289+ return ip_finish_output2 (net , sk , skb );
290290}
291291
292292int ip_mc_output (struct sock * sk , struct sk_buff * skb )
@@ -495,28 +495,26 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from)
495495 skb_copy_secmark (to , from );
496496}
497497
498- static int ip_fragment (struct sock * sk , struct sk_buff * skb ,
498+ static int ip_fragment (struct net * net , struct sock * sk , struct sk_buff * skb ,
499499 unsigned int mtu ,
500- int (* output )(struct sock * , struct sk_buff * ))
500+ int (* output )(struct net * , struct sock * , struct sk_buff * ))
501501{
502502 struct iphdr * iph = ip_hdr (skb );
503503
504504 if ((iph -> frag_off & htons (IP_DF )) == 0 )
505- return ip_do_fragment (sk , skb , output );
505+ return ip_do_fragment (net , sk , skb , output );
506506
507507 if (unlikely (!skb -> ignore_df ||
508508 (IPCB (skb )-> frag_max_size &&
509509 IPCB (skb )-> frag_max_size > mtu ))) {
510- struct net * net = dev_net (skb_rtable (skb )-> dst .dev );
511-
512510 IP_INC_STATS (net , IPSTATS_MIB_FRAGFAILS );
513511 icmp_send (skb , ICMP_DEST_UNREACH , ICMP_FRAG_NEEDED ,
514512 htonl (mtu ));
515513 kfree_skb (skb );
516514 return - EMSGSIZE ;
517515 }
518516
519- return ip_do_fragment (sk , skb , output );
517+ return ip_do_fragment (net , sk , skb , output );
520518}
521519
522520/*
@@ -526,8 +524,8 @@ static int ip_fragment(struct sock *sk, struct sk_buff *skb,
526524 * single device frame, and queue such a frame for sending.
527525 */
528526
529- int ip_do_fragment (struct sock * sk , struct sk_buff * skb ,
530- int (* output )(struct sock * , struct sk_buff * ))
527+ int ip_do_fragment (struct net * net , struct sock * sk , struct sk_buff * skb ,
528+ int (* output )(struct net * , struct sock * , struct sk_buff * ))
531529{
532530 struct iphdr * iph ;
533531 int ptr ;
@@ -537,11 +535,9 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
537535 int offset ;
538536 __be16 not_last_frag ;
539537 struct rtable * rt = skb_rtable (skb );
540- struct net * net ;
541538 int err = 0 ;
542539
543540 dev = rt -> dst .dev ;
544- net = dev_net (dev );
545541
546542 /*
547543 * Point into the IP datagram header.
@@ -631,7 +627,7 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
631627 ip_send_check (iph );
632628 }
633629
634- err = output (sk , skb );
630+ err = output (net , sk , skb );
635631
636632 if (!err )
637633 IP_INC_STATS (net , IPSTATS_MIB_FRAGCREATES );
@@ -771,7 +767,7 @@ int ip_do_fragment(struct sock *sk, struct sk_buff *skb,
771767
772768 ip_send_check (iph );
773769
774- err = output (sk , skb2 );
770+ err = output (net , sk , skb2 );
775771 if (err )
776772 goto fail ;
777773
0 commit comments