]> git.neil.brown.name Git - history.git/commitdiff
[IPV6]: Add IP6CB.
authorHideaki Yoshifuji <yoshfuji@linux-ipv6.org>
Wed, 9 Jun 2004 06:39:40 +0000 (23:39 -0700)
committerDavid S. Miller <davem@nuts.davemloft.net>
Wed, 9 Jun 2004 06:39:40 +0000 (23:39 -0700)
include/linux/ipv6.h
net/ipv6/datagram.c
net/ipv6/exthdrs.c
net/ipv6/ip6_input.c
net/ipv6/ip6_output.c
net/ipv6/raw.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c

index e98637f358171c8014ed41f4233bf71867bf9c38..ccc084d370cd1db7e1ff7cf4421c58960b5197bc 100644 (file)
@@ -192,6 +192,8 @@ struct inet6_skb_parm
        __u16                   dst1;
 };
 
+#define IP6CB(skb)     ((struct inet6_skb_parm*)((skb)->cb))
+
 struct ipv6_pinfo {
        struct in6_addr         saddr;
        struct in6_addr         rcv_saddr;
index fef31fb55f7ef06a3b7c6392812b731eea046ce6..8bd78996b12fb9cd2799f6298772500c0650fefd 100644 (file)
@@ -145,10 +145,8 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
                          (struct in6_addr *)(skb->nh.raw + serr->addr_offset));
                        if (np->sndflow)
                                sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK;
-                       if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
-                               struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
-                               sin->sin6_scope_id = opt->iif;
-                       }
+                       if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+                               sin->sin6_scope_id = IP6CB(skb)->iif;
                } else {
                        ipv6_addr_set(&sin->sin6_addr, 0, 0,
                                      htonl(0xffff),
@@ -167,10 +165,8 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
                        ipv6_addr_copy(&sin->sin6_addr, &skb->nh.ipv6h->saddr);
                        if (np->rxopt.all)
                                datagram_recv_ctl(sk, msg, skb);
-                       if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
-                               struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
-                               sin->sin6_scope_id = opt->iif;
-                       }
+                       if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+                               sin->sin6_scope_id = IP6CB(skb)->iif;
                } else {
                        struct inet_opt *inet = inet_sk(sk);
 
@@ -211,7 +207,7 @@ out:
 int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
 {
        struct ipv6_pinfo *np = inet6_sk(sk);
-       struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
+       struct inet6_skb_parm *opt = IP6CB(skb);
 
        if (np->rxopt.bits.rxinfo) {
                struct in6_pktinfo src_info;
index a5fd7d6447971e90a0a26c8c908843b35884db14..ff12dcf3e8eea58331c5763026fd6851179ceb0d 100644 (file)
@@ -155,7 +155,7 @@ static struct tlvtype_proc tlvprocdestopt_lst[] = {
 static int ipv6_destopt_rcv(struct sk_buff **skbp, unsigned int *nhoffp)
 {
        struct sk_buff *skb = *skbp;
-       struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb;
+       struct inet6_skb_parm *opt = IP6CB(skb);
 
        if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) ||
            !pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) {
@@ -217,7 +217,7 @@ void __init ipv6_nodata_init(void)
 static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp)
 {
        struct sk_buff *skb = *skbp;
-       struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb;
+       struct inet6_skb_parm *opt = IP6CB(skb);
        struct in6_addr *addr;
        struct in6_addr daddr;
        int n, i;
@@ -288,7 +288,7 @@ looped_back:
                        return -1;
                }
                *skbp = skb = skb2;
-               opt = (struct inet6_skb_parm *)skb2->cb;
+               opt = IP6CB(skb2);
                hdr = (struct ipv6_rt_hdr *) skb2->h.raw;
        }
 
@@ -418,7 +418,7 @@ ipv6_invert_rthdr(struct sock *sk, struct ipv6_rt_hdr *hdr)
 static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
 {
        if (skb->nh.raw[optoff+1] == 2) {
-               ((struct inet6_skb_parm*)skb->cb)->ra = optoff;
+               IP6CB(skb)->ra = optoff;
                return 1;
        }
        LIMIT_NETDEBUG(
@@ -482,7 +482,7 @@ static struct tlvtype_proc tlvprochopopt_lst[] = {
 
 int ipv6_parse_hopopts(struct sk_buff *skb, int nhoff)
 {
-       ((struct inet6_skb_parm*)skb->cb)->hop = sizeof(struct ipv6hdr);
+       IP6CB(skb)->hop = sizeof(struct ipv6hdr);
        if (ip6_parse_tlv(tlvprochopopt_lst, skb))
                return sizeof(struct ipv6hdr);
        return -1;
index 61695f33b9ef1d6eb037f20c1e8b5131528f7193..0be5945d3e99ee8f685c52b69f8bd6a8692f3368 100644 (file)
@@ -74,7 +74,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
        /* Store incoming device index. When the packet will
           be queued, we cannot refer to skb->dev anymore.
         */
-       ((struct inet6_skb_parm *)skb->cb)->iif = dev->ifindex;
+       IP6CB(skb)->iif = dev->ifindex;
 
        if (skb->len < sizeof(struct ipv6hdr))
                goto err;
index b9e7b26c5c29e6290e9f8c27ffc13869df09ca40..61dc1cd68be73e9078b919c7845af5a234f3fa1d 100644 (file)
@@ -349,7 +349,7 @@ int ip6_forward(struct sk_buff *skb)
 {
        struct dst_entry *dst = skb->dst;
        struct ipv6hdr *hdr = skb->nh.ipv6h;
-       struct inet6_skb_parm *opt =(struct inet6_skb_parm*)skb->cb;
+       struct inet6_skb_parm *opt = IP6CB(skb);
        
        if (ipv6_devconf.forwarding == 0)
                goto error;
index 3d2961c48955912c8658672d303bda1de3debdff..0e1b275ad98ba68b923c90abd1c2bc7eaf50095b 100644 (file)
@@ -409,10 +409,8 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
                ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
                sin6->sin6_flowinfo = 0;
                sin6->sin6_scope_id = 0;
-               if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
-                       struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
-                       sin6->sin6_scope_id = opt->iif;
-               }
+               if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+                       sin6->sin6_scope_id = IP6CB(skb)->iif;
        }
 
        sock_recv_timestamp(msg, sk, skb);
index 332c8971c6417d3eabb9864b728583cffce4a34d..9885841d97bac9f2b486b6497b7c7097ec6daf20 100644 (file)
@@ -536,8 +536,7 @@ static int tcp_v6_hash_connect(struct sock *sk)
 
 static __inline__ int tcp_v6_iif(struct sk_buff *skb)
 {
-       struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
-       return opt->iif;
+       return IP6CB(skb)->iif;
 }
 
 static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, 
@@ -879,7 +878,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct open_request *req,
                    np->rxopt.bits.srcrt == 2 &&
                    req->af.v6_req.pktopts) {
                        struct sk_buff *pktopts = req->af.v6_req.pktopts;
-                       struct inet6_skb_parm *rxopt = (struct inet6_skb_parm *)pktopts->cb;
+                       struct inet6_skb_parm *rxopt = IP6CB(pktopts);
                        if (rxopt->srcrt)
                                opt = ipv6_invert_rthdr(sk, (struct ipv6_rt_hdr*)(pktopts->nh.raw + rxopt->srcrt));
                }
@@ -932,7 +931,7 @@ static struct or_calltable or_ipv6 = {
 static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
 {
        struct ipv6_pinfo *np = inet6_sk(sk);
-       struct inet6_skb_parm *opt = (struct inet6_skb_parm *)skb->cb;
+       struct inet6_skb_parm *opt = IP6CB(skb);
 
        if (np->rxopt.all) {
                if ((opt->hop && np->rxopt.bits.hopopts) ||
@@ -1305,7 +1304,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
 
        if (np->rxopt.bits.srcrt == 2 &&
            opt == NULL && req->af.v6_req.pktopts) {
-               struct inet6_skb_parm *rxopt = (struct inet6_skb_parm *)req->af.v6_req.pktopts->cb;
+               struct inet6_skb_parm *rxopt = IP6CB(req->af.v6_req.pktopts);
                if (rxopt->srcrt)
                        opt = ipv6_invert_rthdr(sk, (struct ipv6_rt_hdr*)(req->af.v6_req.pktopts->nh.raw+rxopt->srcrt));
        }
index 63ef59317f787e57632bdb101a93d773e735232e..798f266f05519c0cc1103764f4ca1654e309b631 100644 (file)
@@ -432,10 +432,8 @@ try_again:
 
                        if (np->rxopt.all)
                                datagram_recv_ctl(sk, msg, skb);
-                       if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) {
-                               struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb;
-                               sin6->sin6_scope_id = opt->iif;
-                       }
+                       if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL)
+                               sin6->sin6_scope_id = IP6CB(skb)->iif;
                }
        }
        err = copied;