ipv6: add a struct inet6_skb_parm param to ipv6_opt_accepted()
authorEric Dumazet <edumazet@google.com>
Sat, 27 Sep 2014 16:50:56 +0000 (09:50 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 28 Sep 2014 20:35:43 +0000 (16:35 -0400)
ipv6_opt_accepted() assumes IP6CB(skb) holds the struct inet6_skb_parm
that it needs. Lets not assume this, as TCP stack might use a different
place.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ipv6.h
net/dccp/ipv6.c
net/ipv6/af_inet6.c
net/ipv6/syncookies.c
net/ipv6/tcp_ipv6.c

index 7e247e9b87654bb99cabc2288d14ade201b3f965..97f472012438b10a0bcbff9eef6c553d7357ad35 100644 (file)
@@ -288,7 +288,8 @@ struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,
 struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
                                          struct ipv6_txoptions *opt);
 
-bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb);
+bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb,
+                      const struct inet6_skb_parm *opt);
 
 static inline bool ipv6_accept_ra(struct inet6_dev *idev)
 {
index 04cb17d4b0cea9e9a0eac62f7e7f7135d7b9337c..ad2acfe1ca61004e1276e388fdde95c93716d26a 100644 (file)
@@ -404,7 +404,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
        ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
        ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
 
-       if (ipv6_opt_accepted(sk, skb) ||
+       if (ipv6_opt_accepted(sk, skb, IP6CB(skb)) ||
            np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||
            np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {
                atomic_inc(&skb->users);
index e4865a3ebe1d776c7463cfa8a75b7332e9b1d445..34f726f59814ea3ad82395afd6e685787a5dd09b 100644 (file)
@@ -672,10 +672,10 @@ int inet6_sk_rebuild_header(struct sock *sk)
 }
 EXPORT_SYMBOL_GPL(inet6_sk_rebuild_header);
 
-bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb)
+bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb,
+                      const struct inet6_skb_parm *opt)
 {
        const struct ipv6_pinfo *np = inet6_sk(sk);
-       const struct inet6_skb_parm *opt = IP6CB(skb);
 
        if (np->rxopt.all) {
                if ((opt->hop && (np->rxopt.bits.hopopts ||
index c643dc907ce773badc1c8ec9029b20909c21698a..9a2838e93cc5dc2f901c64373378a6dee3533235 100644 (file)
@@ -203,7 +203,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
        ireq->ir_num = ntohs(th->dest);
        ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
        ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
-       if (ipv6_opt_accepted(sk, skb) ||
+       if (ipv6_opt_accepted(sk, skb, &TCP_SKB_CB(skb)->header.h6) ||
            np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||
            np->rxopt.bits.rxhlim || np->rxopt.bits.rxohlim) {
                atomic_inc(&skb->users);
index de51a88bec6f70279fa50b96517d4ee03b5443dd..9400b4326f22346b2edfbebfb8824f5324b3e4f3 100644 (file)
@@ -742,7 +742,8 @@ static void tcp_v6_init_req(struct request_sock *req, struct sock *sk,
                ireq->ir_iif = inet6_iif(skb);
 
        if (!TCP_SKB_CB(skb)->tcp_tw_isn &&
-           (ipv6_opt_accepted(sk, skb) || np->rxopt.bits.rxinfo ||
+           (ipv6_opt_accepted(sk, skb, &TCP_SKB_CB(skb)->header.h6) ||
+            np->rxopt.bits.rxinfo ||
             np->rxopt.bits.rxoinfo || np->rxopt.bits.rxhlim ||
             np->rxopt.bits.rxohlim || np->repflow)) {
                atomic_inc(&skb->users);
@@ -1367,7 +1368,7 @@ ipv6_pktoptions:
                        np->rcv_flowinfo = ip6_flowinfo(ipv6_hdr(opt_skb));
                if (np->repflow)
                        np->flow_label = ip6_flowlabel(ipv6_hdr(opt_skb));
-               if (ipv6_opt_accepted(sk, opt_skb)) {
+               if (ipv6_opt_accepted(sk, opt_skb, &TCP_SKB_CB(opt_skb)->header.h6)) {
                        skb_set_owner_r(opt_skb, sk);
                        opt_skb = xchg(&np->pktoptions, opt_skb);
                } else {