Commit 104360f2 authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji Committed by David S. Miller

[IPV6]: Add IP6CB.

parent b608d6a2
...@@ -192,6 +192,8 @@ struct inet6_skb_parm ...@@ -192,6 +192,8 @@ struct inet6_skb_parm
__u16 dst1; __u16 dst1;
}; };
#define IP6CB(skb) ((struct inet6_skb_parm*)((skb)->cb))
struct ipv6_pinfo { struct ipv6_pinfo {
struct in6_addr saddr; struct in6_addr saddr;
struct in6_addr rcv_saddr; struct in6_addr rcv_saddr;
......
...@@ -145,10 +145,8 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) ...@@ -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)); (struct in6_addr *)(skb->nh.raw + serr->addr_offset));
if (np->sndflow) if (np->sndflow)
sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK; sin->sin6_flowinfo = *(u32*)(skb->nh.raw + serr->addr_offset - 24) & IPV6_FLOWINFO_MASK;
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) { 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 = IP6CB(skb)->iif;
sin->sin6_scope_id = opt->iif;
}
} else { } else {
ipv6_addr_set(&sin->sin6_addr, 0, 0, ipv6_addr_set(&sin->sin6_addr, 0, 0,
htonl(0xffff), htonl(0xffff),
...@@ -167,10 +165,8 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) ...@@ -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); ipv6_addr_copy(&sin->sin6_addr, &skb->nh.ipv6h->saddr);
if (np->rxopt.all) if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb); datagram_recv_ctl(sk, msg, skb);
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) { 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 = IP6CB(skb)->iif;
sin->sin6_scope_id = opt->iif;
}
} else { } else {
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
...@@ -211,7 +207,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) ...@@ -211,7 +207,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
{ {
struct ipv6_pinfo *np = inet6_sk(sk); 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) { if (np->rxopt.bits.rxinfo) {
struct in6_pktinfo src_info; struct in6_pktinfo src_info;
......
...@@ -155,7 +155,7 @@ static struct tlvtype_proc tlvprocdestopt_lst[] = { ...@@ -155,7 +155,7 @@ static struct tlvtype_proc tlvprocdestopt_lst[] = {
static int ipv6_destopt_rcv(struct sk_buff **skbp, unsigned int *nhoffp) static int ipv6_destopt_rcv(struct sk_buff **skbp, unsigned int *nhoffp)
{ {
struct sk_buff *skb = *skbp; 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) || 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))) { !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) ...@@ -217,7 +217,7 @@ void __init ipv6_nodata_init(void)
static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp) static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp)
{ {
struct sk_buff *skb = *skbp; 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 *addr;
struct in6_addr daddr; struct in6_addr daddr;
int n, i; int n, i;
...@@ -288,7 +288,7 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp) ...@@ -288,7 +288,7 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp, unsigned int *nhoffp)
return -1; return -1;
} }
*skbp = skb = skb2; *skbp = skb = skb2;
opt = (struct inet6_skb_parm *)skb2->cb; opt = IP6CB(skb2);
hdr = (struct ipv6_rt_hdr *) skb2->h.raw; hdr = (struct ipv6_rt_hdr *) skb2->h.raw;
} }
...@@ -418,7 +418,7 @@ ipv6_invert_rthdr(struct sock *sk, struct ipv6_rt_hdr *hdr) ...@@ -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) static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
{ {
if (skb->nh.raw[optoff+1] == 2) { if (skb->nh.raw[optoff+1] == 2) {
((struct inet6_skb_parm*)skb->cb)->ra = optoff; IP6CB(skb)->ra = optoff;
return 1; return 1;
} }
LIMIT_NETDEBUG( LIMIT_NETDEBUG(
...@@ -482,7 +482,7 @@ static struct tlvtype_proc tlvprochopopt_lst[] = { ...@@ -482,7 +482,7 @@ static struct tlvtype_proc tlvprochopopt_lst[] = {
int ipv6_parse_hopopts(struct sk_buff *skb, int nhoff) 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)) if (ip6_parse_tlv(tlvprochopopt_lst, skb))
return sizeof(struct ipv6hdr); return sizeof(struct ipv6hdr);
return -1; return -1;
......
...@@ -74,7 +74,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt ...@@ -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 /* Store incoming device index. When the packet will
be queued, we cannot refer to skb->dev anymore. 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)) if (skb->len < sizeof(struct ipv6hdr))
goto err; goto err;
......
...@@ -349,7 +349,7 @@ int ip6_forward(struct sk_buff *skb) ...@@ -349,7 +349,7 @@ int ip6_forward(struct sk_buff *skb)
{ {
struct dst_entry *dst = skb->dst; struct dst_entry *dst = skb->dst;
struct ipv6hdr *hdr = skb->nh.ipv6h; 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) if (ipv6_devconf.forwarding == 0)
goto error; goto error;
......
...@@ -409,10 +409,8 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -409,10 +409,8 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr); ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
sin6->sin6_flowinfo = 0; sin6->sin6_flowinfo = 0;
sin6->sin6_scope_id = 0; sin6->sin6_scope_id = 0;
if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) { 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 = IP6CB(skb)->iif;
sin6->sin6_scope_id = opt->iif;
}
} }
sock_recv_timestamp(msg, sk, skb); sock_recv_timestamp(msg, sk, skb);
......
...@@ -536,8 +536,7 @@ static int tcp_v6_hash_connect(struct sock *sk) ...@@ -536,8 +536,7 @@ static int tcp_v6_hash_connect(struct sock *sk)
static __inline__ int tcp_v6_iif(struct sk_buff *skb) static __inline__ int tcp_v6_iif(struct sk_buff *skb)
{ {
struct inet6_skb_parm *opt = (struct inet6_skb_parm *) skb->cb; return IP6CB(skb)->iif;
return opt->iif;
} }
static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, 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, ...@@ -879,7 +878,7 @@ static int tcp_v6_send_synack(struct sock *sk, struct open_request *req,
np->rxopt.bits.srcrt == 2 && np->rxopt.bits.srcrt == 2 &&
req->af.v6_req.pktopts) { req->af.v6_req.pktopts) {
struct sk_buff *pktopts = 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) if (rxopt->srcrt)
opt = ipv6_invert_rthdr(sk, (struct ipv6_rt_hdr*)(pktopts->nh.raw + 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 = { ...@@ -932,7 +931,7 @@ static struct or_calltable or_ipv6 = {
static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb) static int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb)
{ {
struct ipv6_pinfo *np = inet6_sk(sk); 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 (np->rxopt.all) {
if ((opt->hop && np->rxopt.bits.hopopts) || 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, ...@@ -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 && if (np->rxopt.bits.srcrt == 2 &&
opt == NULL && req->af.v6_req.pktopts) { 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) if (rxopt->srcrt)
opt = ipv6_invert_rthdr(sk, (struct ipv6_rt_hdr*)(req->af.v6_req.pktopts->nh.raw+rxopt->srcrt)); opt = ipv6_invert_rthdr(sk, (struct ipv6_rt_hdr*)(req->af.v6_req.pktopts->nh.raw+rxopt->srcrt));
} }
......
...@@ -432,10 +432,8 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk, ...@@ -432,10 +432,8 @@ static int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,
if (np->rxopt.all) if (np->rxopt.all)
datagram_recv_ctl(sk, msg, skb); datagram_recv_ctl(sk, msg, skb);
if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_LINKLOCAL) { 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 = IP6CB(skb)->iif;
sin6->sin6_scope_id = opt->iif;
}
} }
} }
err = copied; err = copied;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment