Commit 6502ca52 authored by YOSHIFUJI Hideaki / 吉藤英明's avatar YOSHIFUJI Hideaki / 吉藤英明 Committed by David S. Miller

ipv6: Introduce ip6_flowinfo() to extract flowinfo (tclass + flowlabel).

Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3e4e4c1f
...@@ -555,6 +555,11 @@ static inline void ip6_flow_hdr(struct ipv6hdr *hdr, unsigned int tclass, ...@@ -555,6 +555,11 @@ static inline void ip6_flow_hdr(struct ipv6hdr *hdr, unsigned int tclass,
*(__be32 *)hdr = ntohl(0x60000000 | (tclass << 20)) | flowlabel; *(__be32 *)hdr = ntohl(0x60000000 | (tclass << 20)) | flowlabel;
} }
static inline __be32 ip6_flowinfo(const struct ipv6hdr *hdr)
{
return *(__be32 *)hdr & IPV6_FLOWINFO_MASK;
}
/* /*
* Prototypes exported by ipv6 * Prototypes exported by ipv6
*/ */
......
...@@ -360,7 +360,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len) ...@@ -360,7 +360,7 @@ int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len)
struct ipv6hdr, daddr); struct ipv6hdr, daddr);
sin->sin6_addr = ip6h->daddr; sin->sin6_addr = ip6h->daddr;
if (np->sndflow) if (np->sndflow)
sin->sin6_flowinfo = *(__be32 *)ip6h & IPV6_FLOWINFO_MASK; sin->sin6_flowinfo = ip6_flowinfo(ip6h);
if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
sin->sin6_scope_id = IP6CB(skb)->iif; sin->sin6_scope_id = IP6CB(skb)->iif;
} else { } else {
...@@ -491,9 +491,10 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb) ...@@ -491,9 +491,10 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
} }
if (np->rxopt.bits.rxflow && (*(__be32 *)nh & IPV6_FLOWINFO_MASK)) { if (np->rxopt.bits.rxflow) {
__be32 flowinfo = *(__be32 *)nh & IPV6_FLOWINFO_MASK; __be32 flowinfo = ip6_flowinfo((struct ipv6hdr *)nh);
put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); if (flowinfo)
put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo);
} }
/* HbH is allowed only once */ /* HbH is allowed only once */
......
...@@ -994,7 +994,7 @@ void ip6_route_input(struct sk_buff *skb) ...@@ -994,7 +994,7 @@ void ip6_route_input(struct sk_buff *skb)
.flowi6_iif = skb->dev->ifindex, .flowi6_iif = skb->dev->ifindex,
.daddr = iph->daddr, .daddr = iph->daddr,
.saddr = iph->saddr, .saddr = iph->saddr,
.flowlabel = (* (__be32 *) iph) & IPV6_FLOWINFO_MASK, .flowlabel = ip6_flowinfo(iph),
.flowi6_mark = skb->mark, .flowi6_mark = skb->mark,
.flowi6_proto = iph->nexthdr, .flowi6_proto = iph->nexthdr,
}; };
...@@ -1159,7 +1159,7 @@ void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu, ...@@ -1159,7 +1159,7 @@ void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu,
fl6.flowi6_flags = 0; fl6.flowi6_flags = 0;
fl6.daddr = iph->daddr; fl6.daddr = iph->daddr;
fl6.saddr = iph->saddr; fl6.saddr = iph->saddr;
fl6.flowlabel = (*(__be32 *) iph) & IPV6_FLOWINFO_MASK; fl6.flowlabel = ip6_flowinfo(iph);
dst = ip6_route_output(net, NULL, &fl6); dst = ip6_route_output(net, NULL, &fl6);
if (!dst->error) if (!dst->error)
...@@ -1187,7 +1187,7 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) ...@@ -1187,7 +1187,7 @@ void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark)
fl6.flowi6_flags = 0; fl6.flowi6_flags = 0;
fl6.daddr = iph->daddr; fl6.daddr = iph->daddr;
fl6.saddr = iph->saddr; fl6.saddr = iph->saddr;
fl6.flowlabel = (*(__be32 *) iph) & IPV6_FLOWINFO_MASK; fl6.flowlabel = ip6_flowinfo(iph);
dst = ip6_route_output(net, NULL, &fl6); dst = ip6_route_output(net, NULL, &fl6);
if (!dst->error) if (!dst->error)
......
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