diff options
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ipv6_sockglue.c | 89 | ||||
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 19 |
2 files changed, 80 insertions, 28 deletions
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index 0c17dec11c8d..43327264e69c 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
@@ -57,29 +57,11 @@ | |||
57 | 57 | ||
58 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics) __read_mostly; | 58 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics) __read_mostly; |
59 | 59 | ||
60 | static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features) | 60 | static struct inet6_protocol *ipv6_gso_pull_exthdrs(struct sk_buff *skb, |
61 | int proto) | ||
61 | { | 62 | { |
62 | struct sk_buff *segs = ERR_PTR(-EINVAL); | 63 | struct inet6_protocol *ops = NULL; |
63 | struct ipv6hdr *ipv6h; | ||
64 | struct inet6_protocol *ops; | ||
65 | int proto; | ||
66 | 64 | ||
67 | if (unlikely(skb_shinfo(skb)->gso_type & | ||
68 | ~(SKB_GSO_UDP | | ||
69 | SKB_GSO_DODGY | | ||
70 | SKB_GSO_TCP_ECN | | ||
71 | SKB_GSO_TCPV6 | | ||
72 | 0))) | ||
73 | goto out; | ||
74 | |||
75 | if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) | ||
76 | goto out; | ||
77 | |||
78 | ipv6h = skb->nh.ipv6h; | ||
79 | proto = ipv6h->nexthdr; | ||
80 | __skb_pull(skb, sizeof(*ipv6h)); | ||
81 | |||
82 | rcu_read_lock(); | ||
83 | for (;;) { | 65 | for (;;) { |
84 | struct ipv6_opt_hdr *opth; | 66 | struct ipv6_opt_hdr *opth; |
85 | int len; | 67 | int len; |
@@ -88,30 +70,80 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features) | |||
88 | ops = rcu_dereference(inet6_protos[proto]); | 70 | ops = rcu_dereference(inet6_protos[proto]); |
89 | 71 | ||
90 | if (unlikely(!ops)) | 72 | if (unlikely(!ops)) |
91 | goto unlock; | 73 | break; |
92 | 74 | ||
93 | if (!(ops->flags & INET6_PROTO_GSO_EXTHDR)) | 75 | if (!(ops->flags & INET6_PROTO_GSO_EXTHDR)) |
94 | break; | 76 | break; |
95 | } | 77 | } |
96 | 78 | ||
97 | if (unlikely(!pskb_may_pull(skb, 8))) | 79 | if (unlikely(!pskb_may_pull(skb, 8))) |
98 | goto unlock; | 80 | break; |
99 | 81 | ||
100 | opth = (void *)skb->data; | 82 | opth = (void *)skb->data; |
101 | len = opth->hdrlen * 8 + 8; | 83 | len = opth->hdrlen * 8 + 8; |
102 | 84 | ||
103 | if (unlikely(!pskb_may_pull(skb, len))) | 85 | if (unlikely(!pskb_may_pull(skb, len))) |
104 | goto unlock; | 86 | break; |
105 | 87 | ||
106 | proto = opth->nexthdr; | 88 | proto = opth->nexthdr; |
107 | __skb_pull(skb, len); | 89 | __skb_pull(skb, len); |
108 | } | 90 | } |
109 | 91 | ||
110 | skb->h.raw = skb->data; | 92 | return ops; |
111 | if (likely(ops->gso_segment)) | 93 | } |
112 | segs = ops->gso_segment(skb, features); | 94 | |
95 | static int ipv6_gso_send_check(struct sk_buff *skb) | ||
96 | { | ||
97 | struct ipv6hdr *ipv6h; | ||
98 | struct inet6_protocol *ops; | ||
99 | int err = -EINVAL; | ||
100 | |||
101 | if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) | ||
102 | goto out; | ||
113 | 103 | ||
114 | unlock: | 104 | ipv6h = skb->nh.ipv6h; |
105 | __skb_pull(skb, sizeof(*ipv6h)); | ||
106 | err = -EPROTONOSUPPORT; | ||
107 | |||
108 | rcu_read_lock(); | ||
109 | ops = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr); | ||
110 | if (likely(ops && ops->gso_send_check)) { | ||
111 | skb->h.raw = skb->data; | ||
112 | err = ops->gso_send_check(skb); | ||
113 | } | ||
114 | rcu_read_unlock(); | ||
115 | |||
116 | out: | ||
117 | return err; | ||
118 | } | ||
119 | |||
120 | static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, int features) | ||
121 | { | ||
122 | struct sk_buff *segs = ERR_PTR(-EINVAL); | ||
123 | struct ipv6hdr *ipv6h; | ||
124 | struct inet6_protocol *ops; | ||
125 | |||
126 | if (unlikely(skb_shinfo(skb)->gso_type & | ||
127 | ~(SKB_GSO_UDP | | ||
128 | SKB_GSO_DODGY | | ||
129 | SKB_GSO_TCP_ECN | | ||
130 | SKB_GSO_TCPV6 | | ||
131 | 0))) | ||
132 | goto out; | ||
133 | |||
134 | if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) | ||
135 | goto out; | ||
136 | |||
137 | ipv6h = skb->nh.ipv6h; | ||
138 | __skb_pull(skb, sizeof(*ipv6h)); | ||
139 | segs = ERR_PTR(-EPROTONOSUPPORT); | ||
140 | |||
141 | rcu_read_lock(); | ||
142 | ops = ipv6_gso_pull_exthdrs(skb, ipv6h->nexthdr); | ||
143 | if (likely(ops && ops->gso_segment)) { | ||
144 | skb->h.raw = skb->data; | ||
145 | segs = ops->gso_segment(skb, features); | ||
146 | } | ||
115 | rcu_read_unlock(); | 147 | rcu_read_unlock(); |
116 | 148 | ||
117 | if (unlikely(IS_ERR(segs))) | 149 | if (unlikely(IS_ERR(segs))) |
@@ -130,6 +162,7 @@ out: | |||
130 | static struct packet_type ipv6_packet_type = { | 162 | static struct packet_type ipv6_packet_type = { |
131 | .type = __constant_htons(ETH_P_IPV6), | 163 | .type = __constant_htons(ETH_P_IPV6), |
132 | .func = ipv6_rcv, | 164 | .func = ipv6_rcv, |
165 | .gso_send_check = ipv6_gso_send_check, | ||
133 | .gso_segment = ipv6_gso_segment, | 166 | .gso_segment = ipv6_gso_segment, |
134 | }; | 167 | }; |
135 | 168 | ||
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 5bdcb9002cf7..923989d0520d 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -552,6 +552,24 @@ static void tcp_v6_send_check(struct sock *sk, int len, struct sk_buff *skb) | |||
552 | } | 552 | } |
553 | } | 553 | } |
554 | 554 | ||
555 | static int tcp_v6_gso_send_check(struct sk_buff *skb) | ||
556 | { | ||
557 | struct ipv6hdr *ipv6h; | ||
558 | struct tcphdr *th; | ||
559 | |||
560 | if (!pskb_may_pull(skb, sizeof(*th))) | ||
561 | return -EINVAL; | ||
562 | |||
563 | ipv6h = skb->nh.ipv6h; | ||
564 | th = skb->h.th; | ||
565 | |||
566 | th->check = 0; | ||
567 | th->check = ~csum_ipv6_magic(&ipv6h->saddr, &ipv6h->daddr, skb->len, | ||
568 | IPPROTO_TCP, 0); | ||
569 | skb->csum = offsetof(struct tcphdr, check); | ||
570 | skb->ip_summed = CHECKSUM_HW; | ||
571 | return 0; | ||
572 | } | ||
555 | 573 | ||
556 | static void tcp_v6_send_reset(struct sk_buff *skb) | 574 | static void tcp_v6_send_reset(struct sk_buff *skb) |
557 | { | 575 | { |
@@ -1603,6 +1621,7 @@ struct proto tcpv6_prot = { | |||
1603 | static struct inet6_protocol tcpv6_protocol = { | 1621 | static struct inet6_protocol tcpv6_protocol = { |
1604 | .handler = tcp_v6_rcv, | 1622 | .handler = tcp_v6_rcv, |
1605 | .err_handler = tcp_v6_err, | 1623 | .err_handler = tcp_v6_err, |
1624 | .gso_send_check = tcp_v6_gso_send_check, | ||
1606 | .gso_segment = tcp_tso_segment, | 1625 | .gso_segment = tcp_tso_segment, |
1607 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | 1626 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, |
1608 | }; | 1627 | }; |