diff options
Diffstat (limited to 'net/ipv4/ip_output.c')
| -rw-r--r-- | net/ipv4/ip_output.c | 140 |
1 files changed, 77 insertions, 63 deletions
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 3451799e3dbf..7649d7750075 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | #include <linux/string.h> | 51 | #include <linux/string.h> |
| 52 | #include <linux/errno.h> | 52 | #include <linux/errno.h> |
| 53 | #include <linux/highmem.h> | 53 | #include <linux/highmem.h> |
| 54 | #include <linux/slab.h> | ||
| 54 | 55 | ||
| 55 | #include <linux/socket.h> | 56 | #include <linux/socket.h> |
| 56 | #include <linux/sockios.h> | 57 | #include <linux/sockios.h> |
| @@ -88,6 +89,7 @@ __inline__ void ip_send_check(struct iphdr *iph) | |||
| 88 | iph->check = 0; | 89 | iph->check = 0; |
| 89 | iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); | 90 | iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); |
| 90 | } | 91 | } |
| 92 | EXPORT_SYMBOL(ip_send_check); | ||
| 91 | 93 | ||
| 92 | int __ip_local_out(struct sk_buff *skb) | 94 | int __ip_local_out(struct sk_buff *skb) |
| 93 | { | 95 | { |
| @@ -95,8 +97,8 @@ int __ip_local_out(struct sk_buff *skb) | |||
| 95 | 97 | ||
| 96 | iph->tot_len = htons(skb->len); | 98 | iph->tot_len = htons(skb->len); |
| 97 | ip_send_check(iph); | 99 | ip_send_check(iph); |
| 98 | return nf_hook(PF_INET, NF_INET_LOCAL_OUT, skb, NULL, skb_dst(skb)->dev, | 100 | return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, skb, NULL, |
| 99 | dst_output); | 101 | skb_dst(skb)->dev, dst_output); |
| 100 | } | 102 | } |
| 101 | 103 | ||
| 102 | int ip_local_out(struct sk_buff *skb) | 104 | int ip_local_out(struct sk_buff *skb) |
| @@ -119,7 +121,7 @@ static int ip_dev_loopback_xmit(struct sk_buff *newskb) | |||
| 119 | newskb->pkt_type = PACKET_LOOPBACK; | 121 | newskb->pkt_type = PACKET_LOOPBACK; |
| 120 | newskb->ip_summed = CHECKSUM_UNNECESSARY; | 122 | newskb->ip_summed = CHECKSUM_UNNECESSARY; |
| 121 | WARN_ON(!skb_dst(newskb)); | 123 | WARN_ON(!skb_dst(newskb)); |
| 122 | netif_rx(newskb); | 124 | netif_rx_ni(newskb); |
| 123 | return 0; | 125 | return 0; |
| 124 | } | 126 | } |
| 125 | 127 | ||
| @@ -150,15 +152,15 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, | |||
| 150 | iph->version = 4; | 152 | iph->version = 4; |
| 151 | iph->ihl = 5; | 153 | iph->ihl = 5; |
| 152 | iph->tos = inet->tos; | 154 | iph->tos = inet->tos; |
| 153 | if (ip_dont_fragment(sk, &rt->u.dst)) | 155 | if (ip_dont_fragment(sk, &rt->dst)) |
| 154 | iph->frag_off = htons(IP_DF); | 156 | iph->frag_off = htons(IP_DF); |
| 155 | else | 157 | else |
| 156 | iph->frag_off = 0; | 158 | iph->frag_off = 0; |
| 157 | iph->ttl = ip_select_ttl(inet, &rt->u.dst); | 159 | iph->ttl = ip_select_ttl(inet, &rt->dst); |
| 158 | iph->daddr = rt->rt_dst; | 160 | iph->daddr = rt->rt_dst; |
| 159 | iph->saddr = rt->rt_src; | 161 | iph->saddr = rt->rt_src; |
| 160 | iph->protocol = sk->sk_protocol; | 162 | iph->protocol = sk->sk_protocol; |
| 161 | ip_select_ident(iph, &rt->u.dst, sk); | 163 | ip_select_ident(iph, &rt->dst, sk); |
| 162 | 164 | ||
| 163 | if (opt && opt->optlen) { | 165 | if (opt && opt->optlen) { |
| 164 | iph->ihl += opt->optlen>>2; | 166 | iph->ihl += opt->optlen>>2; |
| @@ -171,7 +173,6 @@ int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, | |||
| 171 | /* Send it out. */ | 173 | /* Send it out. */ |
| 172 | return ip_local_out(skb); | 174 | return ip_local_out(skb); |
| 173 | } | 175 | } |
| 174 | |||
| 175 | EXPORT_SYMBOL_GPL(ip_build_and_send_pkt); | 176 | EXPORT_SYMBOL_GPL(ip_build_and_send_pkt); |
| 176 | 177 | ||
| 177 | static inline int ip_finish_output2(struct sk_buff *skb) | 178 | static inline int ip_finish_output2(struct sk_buff *skb) |
| @@ -239,7 +240,7 @@ int ip_mc_output(struct sk_buff *skb) | |||
| 239 | { | 240 | { |
| 240 | struct sock *sk = skb->sk; | 241 | struct sock *sk = skb->sk; |
| 241 | struct rtable *rt = skb_rtable(skb); | 242 | struct rtable *rt = skb_rtable(skb); |
| 242 | struct net_device *dev = rt->u.dst.dev; | 243 | struct net_device *dev = rt->dst.dev; |
| 243 | 244 | ||
| 244 | /* | 245 | /* |
| 245 | * If the indicated interface is up and running, send the packet. | 246 | * If the indicated interface is up and running, send the packet. |
| @@ -271,8 +272,8 @@ int ip_mc_output(struct sk_buff *skb) | |||
| 271 | ) { | 272 | ) { |
| 272 | struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); | 273 | struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); |
| 273 | if (newskb) | 274 | if (newskb) |
| 274 | NF_HOOK(PF_INET, NF_INET_POST_ROUTING, newskb, | 275 | NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, |
| 275 | NULL, newskb->dev, | 276 | newskb, NULL, newskb->dev, |
| 276 | ip_dev_loopback_xmit); | 277 | ip_dev_loopback_xmit); |
| 277 | } | 278 | } |
| 278 | 279 | ||
| @@ -287,12 +288,12 @@ int ip_mc_output(struct sk_buff *skb) | |||
| 287 | if (rt->rt_flags&RTCF_BROADCAST) { | 288 | if (rt->rt_flags&RTCF_BROADCAST) { |
| 288 | struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); | 289 | struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); |
| 289 | if (newskb) | 290 | if (newskb) |
| 290 | NF_HOOK(PF_INET, NF_INET_POST_ROUTING, newskb, NULL, | 291 | NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, newskb, |
| 291 | newskb->dev, ip_dev_loopback_xmit); | 292 | NULL, newskb->dev, ip_dev_loopback_xmit); |
| 292 | } | 293 | } |
| 293 | 294 | ||
| 294 | return NF_HOOK_COND(PF_INET, NF_INET_POST_ROUTING, skb, NULL, skb->dev, | 295 | return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, skb, NULL, |
| 295 | ip_finish_output, | 296 | skb->dev, ip_finish_output, |
| 296 | !(IPCB(skb)->flags & IPSKB_REROUTED)); | 297 | !(IPCB(skb)->flags & IPSKB_REROUTED)); |
| 297 | } | 298 | } |
| 298 | 299 | ||
| @@ -305,22 +306,24 @@ int ip_output(struct sk_buff *skb) | |||
| 305 | skb->dev = dev; | 306 | skb->dev = dev; |
| 306 | skb->protocol = htons(ETH_P_IP); | 307 | skb->protocol = htons(ETH_P_IP); |
| 307 | 308 | ||
| 308 | return NF_HOOK_COND(PF_INET, NF_INET_POST_ROUTING, skb, NULL, dev, | 309 | return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, skb, NULL, dev, |
| 309 | ip_finish_output, | 310 | ip_finish_output, |
| 310 | !(IPCB(skb)->flags & IPSKB_REROUTED)); | 311 | !(IPCB(skb)->flags & IPSKB_REROUTED)); |
| 311 | } | 312 | } |
| 312 | 313 | ||
| 313 | int ip_queue_xmit(struct sk_buff *skb, int ipfragok) | 314 | int ip_queue_xmit(struct sk_buff *skb) |
| 314 | { | 315 | { |
| 315 | struct sock *sk = skb->sk; | 316 | struct sock *sk = skb->sk; |
| 316 | struct inet_sock *inet = inet_sk(sk); | 317 | struct inet_sock *inet = inet_sk(sk); |
| 317 | struct ip_options *opt = inet->opt; | 318 | struct ip_options *opt = inet->opt; |
| 318 | struct rtable *rt; | 319 | struct rtable *rt; |
| 319 | struct iphdr *iph; | 320 | struct iphdr *iph; |
| 321 | int res; | ||
| 320 | 322 | ||
| 321 | /* Skip all of this if the packet is already routed, | 323 | /* Skip all of this if the packet is already routed, |
| 322 | * f.e. by something like SCTP. | 324 | * f.e. by something like SCTP. |
| 323 | */ | 325 | */ |
| 326 | rcu_read_lock(); | ||
| 324 | rt = skb_rtable(skb); | 327 | rt = skb_rtable(skb); |
| 325 | if (rt != NULL) | 328 | if (rt != NULL) |
| 326 | goto packet_routed; | 329 | goto packet_routed; |
| @@ -356,9 +359,9 @@ int ip_queue_xmit(struct sk_buff *skb, int ipfragok) | |||
| 356 | if (ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 0)) | 359 | if (ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 0)) |
| 357 | goto no_route; | 360 | goto no_route; |
| 358 | } | 361 | } |
| 359 | sk_setup_caps(sk, &rt->u.dst); | 362 | sk_setup_caps(sk, &rt->dst); |
| 360 | } | 363 | } |
| 361 | skb_dst_set(skb, dst_clone(&rt->u.dst)); | 364 | skb_dst_set_noref(skb, &rt->dst); |
| 362 | 365 | ||
| 363 | packet_routed: | 366 | packet_routed: |
| 364 | if (opt && opt->is_strictroute && rt->rt_dst != rt->rt_gateway) | 367 | if (opt && opt->is_strictroute && rt->rt_dst != rt->rt_gateway) |
| @@ -369,11 +372,11 @@ packet_routed: | |||
| 369 | skb_reset_network_header(skb); | 372 | skb_reset_network_header(skb); |
| 370 | iph = ip_hdr(skb); | 373 | iph = ip_hdr(skb); |
| 371 | *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); | 374 | *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); |
| 372 | if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok) | 375 | if (ip_dont_fragment(sk, &rt->dst) && !skb->local_df) |
| 373 | iph->frag_off = htons(IP_DF); | 376 | iph->frag_off = htons(IP_DF); |
| 374 | else | 377 | else |
| 375 | iph->frag_off = 0; | 378 | iph->frag_off = 0; |
| 376 | iph->ttl = ip_select_ttl(inet, &rt->u.dst); | 379 | iph->ttl = ip_select_ttl(inet, &rt->dst); |
| 377 | iph->protocol = sk->sk_protocol; | 380 | iph->protocol = sk->sk_protocol; |
| 378 | iph->saddr = rt->rt_src; | 381 | iph->saddr = rt->rt_src; |
| 379 | iph->daddr = rt->rt_dst; | 382 | iph->daddr = rt->rt_dst; |
| @@ -384,19 +387,23 @@ packet_routed: | |||
| 384 | ip_options_build(skb, opt, inet->inet_daddr, rt, 0); | 387 | ip_options_build(skb, opt, inet->inet_daddr, rt, 0); |
| 385 | } | 388 | } |
| 386 | 389 | ||
| 387 | ip_select_ident_more(iph, &rt->u.dst, sk, | 390 | ip_select_ident_more(iph, &rt->dst, sk, |
| 388 | (skb_shinfo(skb)->gso_segs ?: 1) - 1); | 391 | (skb_shinfo(skb)->gso_segs ?: 1) - 1); |
| 389 | 392 | ||
| 390 | skb->priority = sk->sk_priority; | 393 | skb->priority = sk->sk_priority; |
| 391 | skb->mark = sk->sk_mark; | 394 | skb->mark = sk->sk_mark; |
| 392 | 395 | ||
| 393 | return ip_local_out(skb); | 396 | res = ip_local_out(skb); |
| 397 | rcu_read_unlock(); | ||
| 398 | return res; | ||
| 394 | 399 | ||
| 395 | no_route: | 400 | no_route: |
| 401 | rcu_read_unlock(); | ||
| 396 | IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); | 402 | IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTNOROUTES); |
| 397 | kfree_skb(skb); | 403 | kfree_skb(skb); |
| 398 | return -EHOSTUNREACH; | 404 | return -EHOSTUNREACH; |
| 399 | } | 405 | } |
| 406 | EXPORT_SYMBOL(ip_queue_xmit); | ||
| 400 | 407 | ||
| 401 | 408 | ||
| 402 | static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from) | 409 | static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from) |
| @@ -405,7 +412,7 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from) | |||
| 405 | to->priority = from->priority; | 412 | to->priority = from->priority; |
| 406 | to->protocol = from->protocol; | 413 | to->protocol = from->protocol; |
| 407 | skb_dst_drop(to); | 414 | skb_dst_drop(to); |
| 408 | skb_dst_set(to, dst_clone(skb_dst(from))); | 415 | skb_dst_copy(to, from); |
| 409 | to->dev = from->dev; | 416 | to->dev = from->dev; |
| 410 | to->mark = from->mark; | 417 | to->mark = from->mark; |
| 411 | 418 | ||
| @@ -436,17 +443,16 @@ static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from) | |||
| 436 | int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | 443 | int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) |
| 437 | { | 444 | { |
| 438 | struct iphdr *iph; | 445 | struct iphdr *iph; |
| 439 | int raw = 0; | ||
| 440 | int ptr; | 446 | int ptr; |
| 441 | struct net_device *dev; | 447 | struct net_device *dev; |
| 442 | struct sk_buff *skb2; | 448 | struct sk_buff *skb2; |
| 443 | unsigned int mtu, hlen, left, len, ll_rs, pad; | 449 | unsigned int mtu, hlen, left, len, ll_rs; |
| 444 | int offset; | 450 | int offset; |
| 445 | __be16 not_last_frag; | 451 | __be16 not_last_frag; |
| 446 | struct rtable *rt = skb_rtable(skb); | 452 | struct rtable *rt = skb_rtable(skb); |
| 447 | int err = 0; | 453 | int err = 0; |
| 448 | 454 | ||
| 449 | dev = rt->u.dst.dev; | 455 | dev = rt->dst.dev; |
| 450 | 456 | ||
| 451 | /* | 457 | /* |
| 452 | * Point into the IP datagram header. | 458 | * Point into the IP datagram header. |
| @@ -467,7 +473,11 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 467 | */ | 473 | */ |
| 468 | 474 | ||
| 469 | hlen = iph->ihl * 4; | 475 | hlen = iph->ihl * 4; |
| 470 | mtu = dst_mtu(&rt->u.dst) - hlen; /* Size of data space */ | 476 | mtu = dst_mtu(&rt->dst) - hlen; /* Size of data space */ |
| 477 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
| 478 | if (skb->nf_bridge) | ||
| 479 | mtu -= nf_bridge_mtu_reduction(skb); | ||
| 480 | #endif | ||
| 471 | IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE; | 481 | IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE; |
| 472 | 482 | ||
| 473 | /* When frag_list is given, use it. First, check its validity: | 483 | /* When frag_list is given, use it. First, check its validity: |
| @@ -478,9 +488,8 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 478 | * we can switch to copy when see the first bad fragment. | 488 | * we can switch to copy when see the first bad fragment. |
| 479 | */ | 489 | */ |
| 480 | if (skb_has_frags(skb)) { | 490 | if (skb_has_frags(skb)) { |
| 481 | struct sk_buff *frag; | 491 | struct sk_buff *frag, *frag2; |
| 482 | int first_len = skb_pagelen(skb); | 492 | int first_len = skb_pagelen(skb); |
| 483 | int truesizes = 0; | ||
| 484 | 493 | ||
| 485 | if (first_len - hlen > mtu || | 494 | if (first_len - hlen > mtu || |
| 486 | ((first_len - hlen) & 7) || | 495 | ((first_len - hlen) & 7) || |
| @@ -493,18 +502,18 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 493 | if (frag->len > mtu || | 502 | if (frag->len > mtu || |
| 494 | ((frag->len & 7) && frag->next) || | 503 | ((frag->len & 7) && frag->next) || |
| 495 | skb_headroom(frag) < hlen) | 504 | skb_headroom(frag) < hlen) |
| 496 | goto slow_path; | 505 | goto slow_path_clean; |
| 497 | 506 | ||
| 498 | /* Partially cloned skb? */ | 507 | /* Partially cloned skb? */ |
| 499 | if (skb_shared(frag)) | 508 | if (skb_shared(frag)) |
| 500 | goto slow_path; | 509 | goto slow_path_clean; |
| 501 | 510 | ||
| 502 | BUG_ON(frag->sk); | 511 | BUG_ON(frag->sk); |
| 503 | if (skb->sk) { | 512 | if (skb->sk) { |
| 504 | frag->sk = skb->sk; | 513 | frag->sk = skb->sk; |
| 505 | frag->destructor = sock_wfree; | 514 | frag->destructor = sock_wfree; |
| 506 | } | 515 | } |
| 507 | truesizes += frag->truesize; | 516 | skb->truesize -= frag->truesize; |
| 508 | } | 517 | } |
| 509 | 518 | ||
| 510 | /* Everything is OK. Generate! */ | 519 | /* Everything is OK. Generate! */ |
| @@ -514,7 +523,6 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 514 | frag = skb_shinfo(skb)->frag_list; | 523 | frag = skb_shinfo(skb)->frag_list; |
| 515 | skb_frag_list_init(skb); | 524 | skb_frag_list_init(skb); |
| 516 | skb->data_len = first_len - skb_headlen(skb); | 525 | skb->data_len = first_len - skb_headlen(skb); |
| 517 | skb->truesize -= truesizes; | ||
| 518 | skb->len = first_len; | 526 | skb->len = first_len; |
| 519 | iph->tot_len = htons(first_len); | 527 | iph->tot_len = htons(first_len); |
| 520 | iph->frag_off = htons(IP_MF); | 528 | iph->frag_off = htons(IP_MF); |
| @@ -566,18 +574,25 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 566 | } | 574 | } |
| 567 | IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); | 575 | IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); |
| 568 | return err; | 576 | return err; |
| 577 | |||
| 578 | slow_path_clean: | ||
| 579 | skb_walk_frags(skb, frag2) { | ||
| 580 | if (frag2 == frag) | ||
| 581 | break; | ||
| 582 | frag2->sk = NULL; | ||
| 583 | frag2->destructor = NULL; | ||
| 584 | skb->truesize += frag2->truesize; | ||
| 585 | } | ||
| 569 | } | 586 | } |
| 570 | 587 | ||
| 571 | slow_path: | 588 | slow_path: |
| 572 | left = skb->len - hlen; /* Space per frame */ | 589 | left = skb->len - hlen; /* Space per frame */ |
| 573 | ptr = raw + hlen; /* Where to start from */ | 590 | ptr = hlen; /* Where to start from */ |
| 574 | 591 | ||
| 575 | /* for bridged IP traffic encapsulated inside f.e. a vlan header, | 592 | /* for bridged IP traffic encapsulated inside f.e. a vlan header, |
| 576 | * we need to make room for the encapsulating header | 593 | * we need to make room for the encapsulating header |
| 577 | */ | 594 | */ |
| 578 | pad = nf_bridge_pad(skb); | 595 | ll_rs = LL_RESERVED_SPACE_EXTRA(rt->dst.dev, nf_bridge_pad(skb)); |
| 579 | ll_rs = LL_RESERVED_SPACE_EXTRA(rt->u.dst.dev, pad); | ||
| 580 | mtu -= pad; | ||
| 581 | 596 | ||
| 582 | /* | 597 | /* |
| 583 | * Fragment the datagram. | 598 | * Fragment the datagram. |
| @@ -687,7 +702,6 @@ fail: | |||
| 687 | IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); | 702 | IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); |
| 688 | return err; | 703 | return err; |
| 689 | } | 704 | } |
| 690 | |||
| 691 | EXPORT_SYMBOL(ip_fragment); | 705 | EXPORT_SYMBOL(ip_fragment); |
| 692 | 706 | ||
| 693 | int | 707 | int |
| @@ -706,6 +720,7 @@ ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk | |||
| 706 | } | 720 | } |
| 707 | return 0; | 721 | return 0; |
| 708 | } | 722 | } |
| 723 | EXPORT_SYMBOL(ip_generic_getfrag); | ||
| 709 | 724 | ||
| 710 | static inline __wsum | 725 | static inline __wsum |
| 711 | csum_page(struct page *page, int offset, int copy) | 726 | csum_page(struct page *page, int offset, int copy) |
| @@ -823,13 +838,13 @@ int ip_append_data(struct sock *sk, | |||
| 823 | */ | 838 | */ |
| 824 | *rtp = NULL; | 839 | *rtp = NULL; |
| 825 | inet->cork.fragsize = mtu = inet->pmtudisc == IP_PMTUDISC_PROBE ? | 840 | inet->cork.fragsize = mtu = inet->pmtudisc == IP_PMTUDISC_PROBE ? |
| 826 | rt->u.dst.dev->mtu : | 841 | rt->dst.dev->mtu : |
| 827 | dst_mtu(rt->u.dst.path); | 842 | dst_mtu(rt->dst.path); |
| 828 | inet->cork.dst = &rt->u.dst; | 843 | inet->cork.dst = &rt->dst; |
| 829 | inet->cork.length = 0; | 844 | inet->cork.length = 0; |
| 830 | sk->sk_sndmsg_page = NULL; | 845 | sk->sk_sndmsg_page = NULL; |
| 831 | sk->sk_sndmsg_off = 0; | 846 | sk->sk_sndmsg_off = 0; |
| 832 | if ((exthdrlen = rt->u.dst.header_len) != 0) { | 847 | if ((exthdrlen = rt->dst.header_len) != 0) { |
| 833 | length += exthdrlen; | 848 | length += exthdrlen; |
| 834 | transhdrlen += exthdrlen; | 849 | transhdrlen += exthdrlen; |
| 835 | } | 850 | } |
| @@ -842,7 +857,7 @@ int ip_append_data(struct sock *sk, | |||
| 842 | exthdrlen = 0; | 857 | exthdrlen = 0; |
| 843 | mtu = inet->cork.fragsize; | 858 | mtu = inet->cork.fragsize; |
| 844 | } | 859 | } |
| 845 | hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); | 860 | hh_len = LL_RESERVED_SPACE(rt->dst.dev); |
| 846 | 861 | ||
| 847 | fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0); | 862 | fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0); |
| 848 | maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; | 863 | maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; |
| @@ -859,14 +874,16 @@ int ip_append_data(struct sock *sk, | |||
| 859 | */ | 874 | */ |
| 860 | if (transhdrlen && | 875 | if (transhdrlen && |
| 861 | length + fragheaderlen <= mtu && | 876 | length + fragheaderlen <= mtu && |
| 862 | rt->u.dst.dev->features & NETIF_F_V4_CSUM && | 877 | rt->dst.dev->features & NETIF_F_V4_CSUM && |
| 863 | !exthdrlen) | 878 | !exthdrlen) |
| 864 | csummode = CHECKSUM_PARTIAL; | 879 | csummode = CHECKSUM_PARTIAL; |
| 865 | 880 | ||
| 881 | skb = skb_peek_tail(&sk->sk_write_queue); | ||
| 882 | |||
| 866 | inet->cork.length += length; | 883 | inet->cork.length += length; |
| 867 | if (((length> mtu) || !skb_queue_empty(&sk->sk_write_queue)) && | 884 | if (((length > mtu) || (skb && skb_is_gso(skb))) && |
| 868 | (sk->sk_protocol == IPPROTO_UDP) && | 885 | (sk->sk_protocol == IPPROTO_UDP) && |
| 869 | (rt->u.dst.dev->features & NETIF_F_UFO)) { | 886 | (rt->dst.dev->features & NETIF_F_UFO)) { |
| 870 | err = ip_ufo_append_data(sk, getfrag, from, length, hh_len, | 887 | err = ip_ufo_append_data(sk, getfrag, from, length, hh_len, |
| 871 | fragheaderlen, transhdrlen, mtu, | 888 | fragheaderlen, transhdrlen, mtu, |
| 872 | flags); | 889 | flags); |
| @@ -882,7 +899,7 @@ int ip_append_data(struct sock *sk, | |||
| 882 | * adding appropriate IP header. | 899 | * adding appropriate IP header. |
| 883 | */ | 900 | */ |
| 884 | 901 | ||
| 885 | if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) | 902 | if (!skb) |
| 886 | goto alloc_new_skb; | 903 | goto alloc_new_skb; |
| 887 | 904 | ||
| 888 | while (length > 0) { | 905 | while (length > 0) { |
| @@ -914,7 +931,7 @@ alloc_new_skb: | |||
| 914 | fraglen = datalen + fragheaderlen; | 931 | fraglen = datalen + fragheaderlen; |
| 915 | 932 | ||
| 916 | if ((flags & MSG_MORE) && | 933 | if ((flags & MSG_MORE) && |
| 917 | !(rt->u.dst.dev->features&NETIF_F_SG)) | 934 | !(rt->dst.dev->features&NETIF_F_SG)) |
| 918 | alloclen = mtu; | 935 | alloclen = mtu; |
| 919 | else | 936 | else |
| 920 | alloclen = datalen + fragheaderlen; | 937 | alloclen = datalen + fragheaderlen; |
| @@ -925,7 +942,7 @@ alloc_new_skb: | |||
| 925 | * the last. | 942 | * the last. |
| 926 | */ | 943 | */ |
| 927 | if (datalen == length + fraggap) | 944 | if (datalen == length + fraggap) |
| 928 | alloclen += rt->u.dst.trailer_len; | 945 | alloclen += rt->dst.trailer_len; |
| 929 | 946 | ||
| 930 | if (transhdrlen) { | 947 | if (transhdrlen) { |
| 931 | skb = sock_alloc_send_skb(sk, | 948 | skb = sock_alloc_send_skb(sk, |
| @@ -998,7 +1015,7 @@ alloc_new_skb: | |||
| 998 | if (copy > length) | 1015 | if (copy > length) |
| 999 | copy = length; | 1016 | copy = length; |
| 1000 | 1017 | ||
| 1001 | if (!(rt->u.dst.dev->features&NETIF_F_SG)) { | 1018 | if (!(rt->dst.dev->features&NETIF_F_SG)) { |
| 1002 | unsigned int off; | 1019 | unsigned int off; |
| 1003 | 1020 | ||
| 1004 | off = skb->len; | 1021 | off = skb->len; |
| @@ -1093,10 +1110,10 @@ ssize_t ip_append_page(struct sock *sk, struct page *page, | |||
| 1093 | if (inet->cork.flags & IPCORK_OPT) | 1110 | if (inet->cork.flags & IPCORK_OPT) |
| 1094 | opt = inet->cork.opt; | 1111 | opt = inet->cork.opt; |
| 1095 | 1112 | ||
| 1096 | if (!(rt->u.dst.dev->features&NETIF_F_SG)) | 1113 | if (!(rt->dst.dev->features&NETIF_F_SG)) |
| 1097 | return -EOPNOTSUPP; | 1114 | return -EOPNOTSUPP; |
| 1098 | 1115 | ||
| 1099 | hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); | 1116 | hh_len = LL_RESERVED_SPACE(rt->dst.dev); |
| 1100 | mtu = inet->cork.fragsize; | 1117 | mtu = inet->cork.fragsize; |
| 1101 | 1118 | ||
| 1102 | fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0); | 1119 | fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0); |
| @@ -1111,8 +1128,9 @@ ssize_t ip_append_page(struct sock *sk, struct page *page, | |||
| 1111 | return -EINVAL; | 1128 | return -EINVAL; |
| 1112 | 1129 | ||
| 1113 | inet->cork.length += size; | 1130 | inet->cork.length += size; |
| 1114 | if ((sk->sk_protocol == IPPROTO_UDP) && | 1131 | if ((size + skb->len > mtu) && |
| 1115 | (rt->u.dst.dev->features & NETIF_F_UFO)) { | 1132 | (sk->sk_protocol == IPPROTO_UDP) && |
| 1133 | (rt->dst.dev->features & NETIF_F_UFO)) { | ||
| 1116 | skb_shinfo(skb)->gso_size = mtu - fragheaderlen; | 1134 | skb_shinfo(skb)->gso_size = mtu - fragheaderlen; |
| 1117 | skb_shinfo(skb)->gso_type = SKB_GSO_UDP; | 1135 | skb_shinfo(skb)->gso_type = SKB_GSO_UDP; |
| 1118 | } | 1136 | } |
| @@ -1264,8 +1282,8 @@ int ip_push_pending_frames(struct sock *sk) | |||
| 1264 | * If local_df is set too, we still allow to fragment this frame | 1282 | * If local_df is set too, we still allow to fragment this frame |
| 1265 | * locally. */ | 1283 | * locally. */ |
| 1266 | if (inet->pmtudisc >= IP_PMTUDISC_DO || | 1284 | if (inet->pmtudisc >= IP_PMTUDISC_DO || |
| 1267 | (skb->len <= dst_mtu(&rt->u.dst) && | 1285 | (skb->len <= dst_mtu(&rt->dst) && |
| 1268 | ip_dont_fragment(sk, &rt->u.dst))) | 1286 | ip_dont_fragment(sk, &rt->dst))) |
| 1269 | df = htons(IP_DF); | 1287 | df = htons(IP_DF); |
| 1270 | 1288 | ||
| 1271 | if (inet->cork.flags & IPCORK_OPT) | 1289 | if (inet->cork.flags & IPCORK_OPT) |
| @@ -1274,7 +1292,7 @@ int ip_push_pending_frames(struct sock *sk) | |||
| 1274 | if (rt->rt_type == RTN_MULTICAST) | 1292 | if (rt->rt_type == RTN_MULTICAST) |
| 1275 | ttl = inet->mc_ttl; | 1293 | ttl = inet->mc_ttl; |
| 1276 | else | 1294 | else |
| 1277 | ttl = ip_select_ttl(inet, &rt->u.dst); | 1295 | ttl = ip_select_ttl(inet, &rt->dst); |
| 1278 | 1296 | ||
| 1279 | iph = (struct iphdr *)skb->data; | 1297 | iph = (struct iphdr *)skb->data; |
| 1280 | iph->version = 4; | 1298 | iph->version = 4; |
| @@ -1285,7 +1303,7 @@ int ip_push_pending_frames(struct sock *sk) | |||
| 1285 | } | 1303 | } |
| 1286 | iph->tos = inet->tos; | 1304 | iph->tos = inet->tos; |
| 1287 | iph->frag_off = df; | 1305 | iph->frag_off = df; |
| 1288 | ip_select_ident(iph, &rt->u.dst, sk); | 1306 | ip_select_ident(iph, &rt->dst, sk); |
| 1289 | iph->ttl = ttl; | 1307 | iph->ttl = ttl; |
| 1290 | iph->protocol = sk->sk_protocol; | 1308 | iph->protocol = sk->sk_protocol; |
| 1291 | iph->saddr = rt->rt_src; | 1309 | iph->saddr = rt->rt_src; |
| @@ -1298,7 +1316,7 @@ int ip_push_pending_frames(struct sock *sk) | |||
| 1298 | * on dst refcount | 1316 | * on dst refcount |
| 1299 | */ | 1317 | */ |
| 1300 | inet->cork.dst = NULL; | 1318 | inet->cork.dst = NULL; |
| 1301 | skb_dst_set(skb, &rt->u.dst); | 1319 | skb_dst_set(skb, &rt->dst); |
| 1302 | 1320 | ||
| 1303 | if (iph->protocol == IPPROTO_ICMP) | 1321 | if (iph->protocol == IPPROTO_ICMP) |
| 1304 | icmp_out_count(net, ((struct icmphdr *) | 1322 | icmp_out_count(net, ((struct icmphdr *) |
| @@ -1435,7 +1453,3 @@ void __init ip_init(void) | |||
| 1435 | igmp_mc_proc_init(); | 1453 | igmp_mc_proc_init(); |
| 1436 | #endif | 1454 | #endif |
| 1437 | } | 1455 | } |
| 1438 | |||
| 1439 | EXPORT_SYMBOL(ip_generic_getfrag); | ||
| 1440 | EXPORT_SYMBOL(ip_queue_xmit); | ||
| 1441 | EXPORT_SYMBOL(ip_send_check); | ||
