diff options
author | YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org> | 2013-01-13 00:01:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-13 20:17:13 -0500 |
commit | 3e4e4c1f2da66b29ee9379ca29f8dd620c2b5a1f (patch) | |
tree | ee6dfd76e5949b84b8c25136a4563925d0033cfa /net/ipv6 | |
parent | 00494be4546432a11d62ebfeca363256ff9822b5 (diff) |
ipv6: Introduce ip6_flow_hdr() to fill version, tclass and flowlabel.
This is not only for readability but also for optimization.
What we do here is to build the 32bit word at the beginning of the ipv6
header (the "ip6_flow" virtual member of struct ip6_hdr in RFC3542) and
we do not need to read the tclass portion of the target buffer.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ip6_gre.c | 6 | ||||
-rw-r--r-- | net/ipv6/ip6_output.c | 8 | ||||
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 4 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6t_REJECT.c | 2 |
4 files changed, 7 insertions, 13 deletions
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index c727e4712751..db91fe3466a3 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c | |||
@@ -772,9 +772,7 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb, | |||
772 | * Push down and install the IP header. | 772 | * Push down and install the IP header. |
773 | */ | 773 | */ |
774 | ipv6h = ipv6_hdr(skb); | 774 | ipv6h = ipv6_hdr(skb); |
775 | *(__be32 *)ipv6h = fl6->flowlabel | htonl(0x60000000); | 775 | ip6_flow_hdr(ipv6h, INET_ECN_encapsulate(0, dsfield), fl6->flowlabel); |
776 | dsfield = INET_ECN_encapsulate(0, dsfield); | ||
777 | ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield); | ||
778 | ipv6h->hop_limit = tunnel->parms.hop_limit; | 776 | ipv6h->hop_limit = tunnel->parms.hop_limit; |
779 | ipv6h->nexthdr = proto; | 777 | ipv6h->nexthdr = proto; |
780 | ipv6h->saddr = fl6->saddr; | 778 | ipv6h->saddr = fl6->saddr; |
@@ -1240,7 +1238,7 @@ static int ip6gre_header(struct sk_buff *skb, struct net_device *dev, | |||
1240 | struct ipv6hdr *ipv6h = (struct ipv6hdr *)skb_push(skb, t->hlen); | 1238 | struct ipv6hdr *ipv6h = (struct ipv6hdr *)skb_push(skb, t->hlen); |
1241 | __be16 *p = (__be16 *)(ipv6h+1); | 1239 | __be16 *p = (__be16 *)(ipv6h+1); |
1242 | 1240 | ||
1243 | *(__be32 *)ipv6h = t->fl.u.ip6.flowlabel | htonl(0x60000000); | 1241 | ip6_flow_hdr(ipv6h, 0, t->fl.u.ip6.flowlabel); |
1244 | ipv6h->hop_limit = t->parms.hop_limit; | 1242 | ipv6h->hop_limit = t->parms.hop_limit; |
1245 | ipv6h->nexthdr = NEXTHDR_GRE; | 1243 | ipv6h->nexthdr = NEXTHDR_GRE; |
1246 | ipv6h->saddr = t->parms.laddr; | 1244 | ipv6h->saddr = t->parms.laddr; |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 5552d13ae92f..9250c696de9d 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -216,7 +216,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, | |||
216 | if (hlimit < 0) | 216 | if (hlimit < 0) |
217 | hlimit = ip6_dst_hoplimit(dst); | 217 | hlimit = ip6_dst_hoplimit(dst); |
218 | 218 | ||
219 | *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl6->flowlabel; | 219 | ip6_flow_hdr(hdr, tclass, fl6->flowlabel); |
220 | 220 | ||
221 | hdr->payload_len = htons(seg_len); | 221 | hdr->payload_len = htons(seg_len); |
222 | hdr->nexthdr = proto; | 222 | hdr->nexthdr = proto; |
@@ -267,7 +267,7 @@ int ip6_nd_hdr(struct sock *sk, struct sk_buff *skb, struct net_device *dev, | |||
267 | skb_put(skb, sizeof(struct ipv6hdr)); | 267 | skb_put(skb, sizeof(struct ipv6hdr)); |
268 | hdr = ipv6_hdr(skb); | 268 | hdr = ipv6_hdr(skb); |
269 | 269 | ||
270 | *(__be32*)hdr = htonl(0x60000000); | 270 | ip6_flow_hdr(hdr, 0, 0); |
271 | 271 | ||
272 | hdr->payload_len = htons(len); | 272 | hdr->payload_len = htons(len); |
273 | hdr->nexthdr = proto; | 273 | hdr->nexthdr = proto; |
@@ -1548,9 +1548,7 @@ int ip6_push_pending_frames(struct sock *sk) | |||
1548 | skb_reset_network_header(skb); | 1548 | skb_reset_network_header(skb); |
1549 | hdr = ipv6_hdr(skb); | 1549 | hdr = ipv6_hdr(skb); |
1550 | 1550 | ||
1551 | *(__be32*)hdr = fl6->flowlabel | | 1551 | ip6_flow_hdr(hdr, np->cork.tclass, fl6->flowlabel); |
1552 | htonl(0x60000000 | ((int)np->cork.tclass << 20)); | ||
1553 | |||
1554 | hdr->hop_limit = np->cork.hop_limit; | 1552 | hdr->hop_limit = np->cork.hop_limit; |
1555 | hdr->nexthdr = proto; | 1553 | hdr->nexthdr = proto; |
1556 | hdr->saddr = fl6->saddr; | 1554 | hdr->saddr = fl6->saddr; |
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index a14f28b280f5..fff83cbc197f 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -1030,9 +1030,7 @@ static int ip6_tnl_xmit2(struct sk_buff *skb, | |||
1030 | skb_push(skb, sizeof(struct ipv6hdr)); | 1030 | skb_push(skb, sizeof(struct ipv6hdr)); |
1031 | skb_reset_network_header(skb); | 1031 | skb_reset_network_header(skb); |
1032 | ipv6h = ipv6_hdr(skb); | 1032 | ipv6h = ipv6_hdr(skb); |
1033 | *(__be32*)ipv6h = fl6->flowlabel | htonl(0x60000000); | 1033 | ip6_flow_hdr(ipv6h, INET_ECN_encapsulate(0, dsfield), fl6->flowlabel); |
1034 | dsfield = INET_ECN_encapsulate(0, dsfield); | ||
1035 | ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield); | ||
1036 | ipv6h->hop_limit = t->parms.hop_limit; | 1034 | ipv6h->hop_limit = t->parms.hop_limit; |
1037 | ipv6h->nexthdr = proto; | 1035 | ipv6h->nexthdr = proto; |
1038 | ipv6h->saddr = fl6->saddr; | 1036 | ipv6h->saddr = fl6->saddr; |
diff --git a/net/ipv6/netfilter/ip6t_REJECT.c b/net/ipv6/netfilter/ip6t_REJECT.c index fd4fb34c51c7..8e75b6f3db91 100644 --- a/net/ipv6/netfilter/ip6t_REJECT.c +++ b/net/ipv6/netfilter/ip6t_REJECT.c | |||
@@ -126,7 +126,7 @@ static void send_reset(struct net *net, struct sk_buff *oldskb) | |||
126 | skb_put(nskb, sizeof(struct ipv6hdr)); | 126 | skb_put(nskb, sizeof(struct ipv6hdr)); |
127 | skb_reset_network_header(nskb); | 127 | skb_reset_network_header(nskb); |
128 | ip6h = ipv6_hdr(nskb); | 128 | ip6h = ipv6_hdr(nskb); |
129 | *(__be32 *)ip6h = htonl(0x60000000 | (tclass << 20)); | 129 | ip6_flow_hdr(ip6h, tclass, 0); |
130 | ip6h->hop_limit = ip6_dst_hoplimit(dst); | 130 | ip6h->hop_limit = ip6_dst_hoplimit(dst); |
131 | ip6h->nexthdr = IPPROTO_TCP; | 131 | ip6h->nexthdr = IPPROTO_TCP; |
132 | ip6h->saddr = oip6h->daddr; | 132 | ip6h->saddr = oip6h->daddr; |