Lines Matching refs:skb
59 static int ip6_finish_output2(struct sk_buff *skb) in ip6_finish_output2() argument
61 struct dst_entry *dst = skb_dst(skb); in ip6_finish_output2()
67 skb->protocol = htons(ETH_P_IPV6); in ip6_finish_output2()
68 skb->dev = dev; in ip6_finish_output2()
70 if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr)) { in ip6_finish_output2()
71 struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); in ip6_finish_output2()
73 if (!(dev->flags & IFF_LOOPBACK) && sk_mc_loop(skb->sk) && in ip6_finish_output2()
74 ((mroute6_socket(dev_net(dev), skb) && in ip6_finish_output2()
75 !(IP6CB(skb)->flags & IP6SKB_FORWARDED)) || in ip6_finish_output2()
76 ipv6_chk_mcast_addr(dev, &ipv6_hdr(skb)->daddr, in ip6_finish_output2()
77 &ipv6_hdr(skb)->saddr))) { in ip6_finish_output2()
78 struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); in ip6_finish_output2()
88 if (ipv6_hdr(skb)->hop_limit == 0) { in ip6_finish_output2()
91 kfree_skb(skb); in ip6_finish_output2()
97 skb->len); in ip6_finish_output2()
99 if (IPV6_ADDR_MC_SCOPE(&ipv6_hdr(skb)->daddr) <= in ip6_finish_output2()
102 kfree_skb(skb); in ip6_finish_output2()
113 ret = dst_neigh_output(dst, neigh, skb); in ip6_finish_output2()
121 kfree_skb(skb); in ip6_finish_output2()
125 static int ip6_finish_output(struct sk_buff *skb) in ip6_finish_output() argument
127 if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) || in ip6_finish_output()
128 dst_allfrag(skb_dst(skb)) || in ip6_finish_output()
129 (IP6CB(skb)->frag_max_size && skb->len > IP6CB(skb)->frag_max_size)) in ip6_finish_output()
130 return ip6_fragment(skb, ip6_finish_output2); in ip6_finish_output()
132 return ip6_finish_output2(skb); in ip6_finish_output()
135 int ip6_output(struct sock *sk, struct sk_buff *skb) in ip6_output() argument
137 struct net_device *dev = skb_dst(skb)->dev; in ip6_output()
138 struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); in ip6_output()
142 kfree_skb(skb); in ip6_output()
146 return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, NULL, dev, in ip6_output()
148 !(IP6CB(skb)->flags & IP6SKB_REROUTED)); in ip6_output()
155 int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, in ip6_xmit() argument
161 struct dst_entry *dst = skb_dst(skb); in ip6_xmit()
164 int seg_len = skb->len; in ip6_xmit()
178 if (skb_headroom(skb) < head_room) { in ip6_xmit()
179 struct sk_buff *skb2 = skb_realloc_headroom(skb, head_room); in ip6_xmit()
181 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), in ip6_xmit()
183 kfree_skb(skb); in ip6_xmit()
186 consume_skb(skb); in ip6_xmit()
187 skb = skb2; in ip6_xmit()
188 skb_set_owner_w(skb, sk); in ip6_xmit()
191 ipv6_push_frag_opts(skb, opt, &proto); in ip6_xmit()
193 ipv6_push_nfrag_opts(skb, opt, &proto, &first_hop); in ip6_xmit()
196 skb_push(skb, sizeof(struct ipv6hdr)); in ip6_xmit()
197 skb_reset_network_header(skb); in ip6_xmit()
198 hdr = ipv6_hdr(skb); in ip6_xmit()
208 ip6_flow_hdr(hdr, tclass, ip6_make_flowlabel(net, skb, fl6->flowlabel, in ip6_xmit()
218 skb->protocol = htons(ETH_P_IPV6); in ip6_xmit()
219 skb->priority = sk->sk_priority; in ip6_xmit()
220 skb->mark = sk->sk_mark; in ip6_xmit()
223 if ((skb->len <= mtu) || skb->ignore_df || skb_is_gso(skb)) { in ip6_xmit()
224 IP6_UPD_PO_STATS(net, ip6_dst_idev(skb_dst(skb)), in ip6_xmit()
225 IPSTATS_MIB_OUT, skb->len); in ip6_xmit()
226 return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, skb, NULL, in ip6_xmit()
230 skb->dev = dst->dev; in ip6_xmit()
232 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_FRAGFAILS); in ip6_xmit()
233 kfree_skb(skb); in ip6_xmit()
238 static int ip6_call_ra_chain(struct sk_buff *skb, int sel) in ip6_call_ra_chain() argument
248 sk->sk_bound_dev_if == skb->dev->ifindex)) { in ip6_call_ra_chain()
250 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); in ip6_call_ra_chain()
259 rawv6_rcv(last, skb); in ip6_call_ra_chain()
267 static int ip6_forward_proxy_check(struct sk_buff *skb) in ip6_forward_proxy_check() argument
269 struct ipv6hdr *hdr = ipv6_hdr(skb); in ip6_forward_proxy_check()
275 offset = ipv6_skip_exthdr(skb, sizeof(*hdr), &nexthdr, &frag_off); in ip6_forward_proxy_check()
284 if (!pskb_may_pull(skb, (skb_network_header(skb) + in ip6_forward_proxy_check()
285 offset + 1 - skb->data))) in ip6_forward_proxy_check()
288 icmp6 = (struct icmp6hdr *)(skb_network_header(skb) + offset); in ip6_forward_proxy_check()
312 dst_link_failure(skb); in ip6_forward_proxy_check()
319 static inline int ip6_forward_finish(struct sk_buff *skb) in ip6_forward_finish() argument
321 return dst_output(skb); in ip6_forward_finish()
345 static bool ip6_pkt_too_big(const struct sk_buff *skb, unsigned int mtu) in ip6_pkt_too_big() argument
347 if (skb->len <= mtu) in ip6_pkt_too_big()
351 if (IP6CB(skb)->frag_max_size && IP6CB(skb)->frag_max_size > mtu) in ip6_pkt_too_big()
354 if (skb->ignore_df) in ip6_pkt_too_big()
357 if (skb_is_gso(skb) && skb_gso_network_seglen(skb) <= mtu) in ip6_pkt_too_big()
363 int ip6_forward(struct sk_buff *skb) in ip6_forward() argument
365 struct dst_entry *dst = skb_dst(skb); in ip6_forward()
366 struct ipv6hdr *hdr = ipv6_hdr(skb); in ip6_forward()
367 struct inet6_skb_parm *opt = IP6CB(skb); in ip6_forward()
374 if (skb->pkt_type != PACKET_HOST) in ip6_forward()
377 if (unlikely(skb->sk)) in ip6_forward()
380 if (skb_warn_if_lro(skb)) in ip6_forward()
383 if (!xfrm6_policy_check(NULL, XFRM_POLICY_FWD, skb)) { in ip6_forward()
389 skb_forward_csum(skb); in ip6_forward()
405 if (ip6_call_ra_chain(skb, ntohs(opt->ra))) in ip6_forward()
414 skb->dev = dst->dev; in ip6_forward()
415 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT, 0); in ip6_forward()
419 kfree_skb(skb); in ip6_forward()
425 pneigh_lookup(&nd_tbl, net, &hdr->daddr, skb->dev, 0)) { in ip6_forward()
426 int proxied = ip6_forward_proxy_check(skb); in ip6_forward()
428 return ip6_input(skb); in ip6_forward()
436 if (!xfrm6_route_forward(skb)) { in ip6_forward()
441 dst = skb_dst(skb); in ip6_forward()
447 if (skb->dev == dst->dev && opt->srcrt == 0 && !skb_sec_path(skb)) { in ip6_forward()
469 ndisc_send_redirect(skb, target); in ip6_forward()
480 icmpv6_send(skb, ICMPV6_DEST_UNREACH, in ip6_forward()
490 if (ip6_pkt_too_big(skb, mtu)) { in ip6_forward()
492 skb->dev = dst->dev; in ip6_forward()
493 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); in ip6_forward()
498 kfree_skb(skb); in ip6_forward()
502 if (skb_cow(skb, dst->dev->hard_header_len)) { in ip6_forward()
508 hdr = ipv6_hdr(skb); in ip6_forward()
515 IP6_ADD_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len); in ip6_forward()
516 return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, skb, skb->dev, dst->dev, in ip6_forward()
522 kfree_skb(skb); in ip6_forward()
557 int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) in ip6_fragment() argument
560 struct rt6_info *rt = (struct rt6_info *)skb_dst(skb); in ip6_fragment()
561 struct ipv6_pinfo *np = skb->sk && !dev_recursion_level() ? in ip6_fragment()
562 inet6_sk(skb->sk) : NULL; in ip6_fragment()
570 struct net *net = dev_net(skb_dst(skb)->dev); in ip6_fragment()
572 err = ip6_find_1stfragopt(skb, &prevhdr); in ip6_fragment()
578 mtu = ip6_skb_dst_mtu(skb); in ip6_fragment()
583 if (unlikely(!skb->ignore_df && skb->len > mtu) || in ip6_fragment()
584 (IP6CB(skb)->frag_max_size && in ip6_fragment()
585 IP6CB(skb)->frag_max_size > mtu)) { in ip6_fragment()
586 if (skb->sk && dst_allfrag(skb_dst(skb))) in ip6_fragment()
587 sk_nocaps_add(skb->sk, NETIF_F_GSO_MASK); in ip6_fragment()
589 skb->dev = skb_dst(skb)->dev; in ip6_fragment()
590 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); in ip6_fragment()
591 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), in ip6_fragment()
593 kfree_skb(skb); in ip6_fragment()
603 if (skb_has_frag_list(skb)) { in ip6_fragment()
604 int first_len = skb_pagelen(skb); in ip6_fragment()
609 skb_cloned(skb)) in ip6_fragment()
612 skb_walk_frags(skb, frag) { in ip6_fragment()
624 if (skb->sk) { in ip6_fragment()
625 frag->sk = skb->sk; in ip6_fragment()
628 skb->truesize -= frag->truesize; in ip6_fragment()
633 frag = skb_shinfo(skb)->frag_list; in ip6_fragment()
634 skb_frag_list_init(skb); in ip6_fragment()
638 tmp_hdr = kmemdup(skb_network_header(skb), hlen, GFP_ATOMIC); in ip6_fragment()
640 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), in ip6_fragment()
645 __skb_pull(skb, hlen); in ip6_fragment()
646 fh = (struct frag_hdr *)__skb_push(skb, sizeof(struct frag_hdr)); in ip6_fragment()
647 __skb_push(skb, hlen); in ip6_fragment()
648 skb_reset_network_header(skb); in ip6_fragment()
649 memcpy(skb_network_header(skb), tmp_hdr, hlen); in ip6_fragment()
657 first_len = skb_pagelen(skb); in ip6_fragment()
658 skb->data_len = first_len - skb_headlen(skb); in ip6_fragment()
659 skb->len = first_len; in ip6_fragment()
660 ipv6_hdr(skb)->payload_len = htons(first_len - in ip6_fragment()
676 offset += skb->len - hlen - sizeof(struct frag_hdr); in ip6_fragment()
686 ip6_copy_metadata(frag, skb); in ip6_fragment()
689 err = output(skb); in ip6_fragment()
697 skb = frag; in ip6_fragment()
698 frag = skb->next; in ip6_fragment()
699 skb->next = NULL; in ip6_fragment()
719 skb_walk_frags(skb, frag2) { in ip6_fragment()
724 skb->truesize += frag2->truesize; in ip6_fragment()
729 if ((skb->ip_summed == CHECKSUM_PARTIAL) && in ip6_fragment()
730 skb_checksum_help(skb)) in ip6_fragment()
733 left = skb->len - hlen; /* Space per frame */ in ip6_fragment()
764 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), in ip6_fragment()
774 ip6_copy_metadata(frag, skb); in ip6_fragment()
786 if (skb->sk) in ip6_fragment()
787 skb_set_owner_w(frag, skb->sk); in ip6_fragment()
792 skb_copy_from_linear_data(skb, skb_network_header(frag), hlen); in ip6_fragment()
808 BUG_ON(skb_copy_bits(skb, ptr, skb_transport_header(frag), in ip6_fragment()
828 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), in ip6_fragment()
831 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), in ip6_fragment()
833 consume_skb(skb); in ip6_fragment()
837 IP6_INC_STATS(net, ip6_dst_idev(skb_dst(skb)), in ip6_fragment()
839 kfree_skb(skb); in ip6_fragment()
1052 int odd, struct sk_buff *skb), in ip6_ufo_append_data() argument
1058 struct sk_buff *skb; in ip6_ufo_append_data() local
1066 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL) { in ip6_ufo_append_data()
1067 skb = sock_alloc_send_skb(sk, in ip6_ufo_append_data()
1070 if (skb == NULL) in ip6_ufo_append_data()
1074 skb_reserve(skb, hh_len); in ip6_ufo_append_data()
1077 skb_put(skb, fragheaderlen + transhdrlen); in ip6_ufo_append_data()
1080 skb_reset_network_header(skb); in ip6_ufo_append_data()
1083 skb->transport_header = skb->network_header + fragheaderlen; in ip6_ufo_append_data()
1085 skb->protocol = htons(ETH_P_IPV6); in ip6_ufo_append_data()
1086 skb->csum = 0; in ip6_ufo_append_data()
1088 __skb_queue_tail(&sk->sk_write_queue, skb); in ip6_ufo_append_data()
1089 } else if (skb_is_gso(skb)) { in ip6_ufo_append_data()
1093 skb->ip_summed = CHECKSUM_PARTIAL; in ip6_ufo_append_data()
1097 skb_shinfo(skb)->gso_size = (mtu - fragheaderlen - in ip6_ufo_append_data()
1099 skb_shinfo(skb)->gso_type = SKB_GSO_UDP; in ip6_ufo_append_data()
1101 skb_shinfo(skb)->ip6_frag_id = fhdr.identification; in ip6_ufo_append_data()
1104 return skb_append_datato_frags(sk, skb, getfrag, from, in ip6_ufo_append_data()
1123 struct sk_buff *skb, in ip6_append_data_mtu() argument
1128 if (skb == NULL) { in ip6_append_data_mtu()
1145 int offset, int len, int odd, struct sk_buff *skb), in ip6_append_data() argument
1153 struct sk_buff *skb, *skb_prev = NULL; in ip6_append_data() local
1303 skb = skb_peek_tail(&sk->sk_write_queue); in ip6_append_data()
1305 if ((skb && skb_is_gso(skb)) || in ip6_append_data()
1319 if (!skb) in ip6_append_data()
1324 copy = (cork->length <= mtu && !(cork->flags & IPCORK_ALLFRAG) ? mtu : maxfraglen) - skb->len; in ip6_append_data()
1326 copy = maxfraglen - skb->len; in ip6_append_data()
1336 if (skb) in ip6_append_data()
1337 fraggap = skb->len - maxfraglen; in ip6_append_data()
1341 if (skb == NULL || skb_prev == NULL) in ip6_append_data()
1343 fragheaderlen, skb, rt, in ip6_append_data()
1346 skb_prev = skb; in ip6_append_data()
1388 skb = sock_alloc_send_skb(sk, in ip6_append_data()
1392 skb = NULL; in ip6_append_data()
1395 skb = sock_wmalloc(sk, in ip6_append_data()
1398 if (unlikely(skb == NULL)) in ip6_append_data()
1401 if (skb == NULL) in ip6_append_data()
1406 skb->protocol = htons(ETH_P_IPV6); in ip6_append_data()
1407 skb->ip_summed = CHECKSUM_NONE; in ip6_append_data()
1408 skb->csum = 0; in ip6_append_data()
1410 skb_reserve(skb, hh_len + sizeof(struct frag_hdr) + in ip6_append_data()
1414 skb_shinfo(skb)->tx_flags = tx_flags; in ip6_append_data()
1416 skb_shinfo(skb)->tskey = tskey; in ip6_append_data()
1422 data = skb_put(skb, fraglen); in ip6_append_data()
1423 skb_set_network_header(skb, exthdrlen); in ip6_append_data()
1425 skb->transport_header = (skb->network_header + in ip6_append_data()
1428 skb->csum = skb_copy_and_csum_bits( in ip6_append_data()
1432 skb->csum); in ip6_append_data()
1438 copy, fraggap, skb) < 0) { in ip6_append_data()
1440 kfree_skb(skb); in ip6_append_data()
1453 __skb_queue_tail(&sk->sk_write_queue, skb); in ip6_append_data()
1463 off = skb->len; in ip6_append_data()
1464 if (getfrag(from, skb_put(skb, copy), in ip6_append_data()
1465 offset, copy, off, skb) < 0) { in ip6_append_data()
1466 __skb_trim(skb, off); in ip6_append_data()
1471 int i = skb_shinfo(skb)->nr_frags; in ip6_append_data()
1478 if (!skb_can_coalesce(skb, i, pfrag->page, in ip6_append_data()
1484 __skb_fill_page_desc(skb, i, pfrag->page, in ip6_append_data()
1486 skb_shinfo(skb)->nr_frags = ++i; in ip6_append_data()
1492 offset, copy, skb->len, skb) < 0) in ip6_append_data()
1496 skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); in ip6_append_data()
1497 skb->len += copy; in ip6_append_data()
1498 skb->data_len += copy; in ip6_append_data()
1499 skb->truesize += copy; in ip6_append_data()
1538 struct sk_buff *skb, *tmp_skb; in ip6_push_pending_frames() local
1551 if ((skb = __skb_dequeue(&sk->sk_write_queue)) == NULL) in ip6_push_pending_frames()
1553 tail_skb = &(skb_shinfo(skb)->frag_list); in ip6_push_pending_frames()
1556 if (skb->data < skb_network_header(skb)) in ip6_push_pending_frames()
1557 __skb_pull(skb, skb_network_offset(skb)); in ip6_push_pending_frames()
1559 __skb_pull(tmp_skb, skb_network_header_len(skb)); in ip6_push_pending_frames()
1562 skb->len += tmp_skb->len; in ip6_push_pending_frames()
1563 skb->data_len += tmp_skb->len; in ip6_push_pending_frames()
1564 skb->truesize += tmp_skb->truesize; in ip6_push_pending_frames()
1570 skb->ignore_df = ip6_sk_ignore_df(sk); in ip6_push_pending_frames()
1573 __skb_pull(skb, skb_network_header_len(skb)); in ip6_push_pending_frames()
1575 ipv6_push_frag_opts(skb, opt, &proto); in ip6_push_pending_frames()
1577 ipv6_push_nfrag_opts(skb, opt, &proto, &final_dst); in ip6_push_pending_frames()
1579 skb_push(skb, sizeof(struct ipv6hdr)); in ip6_push_pending_frames()
1580 skb_reset_network_header(skb); in ip6_push_pending_frames()
1581 hdr = ipv6_hdr(skb); in ip6_push_pending_frames()
1584 ip6_make_flowlabel(net, skb, fl6->flowlabel, in ip6_push_pending_frames()
1591 skb->priority = sk->sk_priority; in ip6_push_pending_frames()
1592 skb->mark = sk->sk_mark; in ip6_push_pending_frames()
1594 skb_dst_set(skb, dst_clone(&rt->dst)); in ip6_push_pending_frames()
1595 IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len); in ip6_push_pending_frames()
1597 struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); in ip6_push_pending_frames()
1599 ICMP6MSGOUT_INC_STATS(net, idev, icmp6_hdr(skb)->icmp6_type); in ip6_push_pending_frames()
1603 err = ip6_local_out(skb); in ip6_push_pending_frames()
1622 struct sk_buff *skb; in ip6_flush_pending_frames() local
1624 while ((skb = __skb_dequeue_tail(&sk->sk_write_queue)) != NULL) { in ip6_flush_pending_frames()
1625 if (skb_dst(skb)) in ip6_flush_pending_frames()
1626 IP6_INC_STATS(sock_net(sk), ip6_dst_idev(skb_dst(skb)), in ip6_flush_pending_frames()
1628 kfree_skb(skb); in ip6_flush_pending_frames()