diff options
author | yangxingwu <xingwu.yang@gmail.com> | 2019-07-10 09:14:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-07-11 17:43:25 -0400 |
commit | 416e8126a2672f6e91e9e81c6f5c07cf46808b13 (patch) | |
tree | 022663d29eb3e3629f3004d2b02c72deb2e89209 | |
parent | 311633b604063a8a5d3fbc74d0565b42df721f68 (diff) |
ipv6: Use ipv6_authlen for len
The length of AH header is computed manually as (hp->hdrlen+2)<<2.
However, in include/linux/ipv6.h, a macro named ipv6_authlen is
already defined for exactly the same job. This commit replaces
the manual computation code with the macro.
Signed-off-by: yangxingwu <xingwu.yang@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv6/ah6.c | 4 | ||||
-rw-r--r-- | net/ipv6/exthdrs_core.c | 2 | ||||
-rw-r--r-- | net/ipv6/ip6_tunnel.c | 2 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6t_ah.c | 2 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6t_ipv6header.c | 2 | ||||
-rw-r--r-- | net/ipv6/netfilter/nf_conntrack_reasm.c | 2 | ||||
-rw-r--r-- | net/ipv6/netfilter/nf_log_ipv6.c | 2 |
7 files changed, 8 insertions, 8 deletions
diff --git a/net/ipv6/ah6.c b/net/ipv6/ah6.c index 25e1172fd1c3..95835e8d99aa 100644 --- a/net/ipv6/ah6.c +++ b/net/ipv6/ah6.c | |||
@@ -464,7 +464,7 @@ static void ah6_input_done(struct crypto_async_request *base, int err) | |||
464 | struct ah_data *ahp = x->data; | 464 | struct ah_data *ahp = x->data; |
465 | struct ip_auth_hdr *ah = ip_auth_hdr(skb); | 465 | struct ip_auth_hdr *ah = ip_auth_hdr(skb); |
466 | int hdr_len = skb_network_header_len(skb); | 466 | int hdr_len = skb_network_header_len(skb); |
467 | int ah_hlen = (ah->hdrlen + 2) << 2; | 467 | int ah_hlen = ipv6_authlen(ah); |
468 | 468 | ||
469 | if (err) | 469 | if (err) |
470 | goto out; | 470 | goto out; |
@@ -546,7 +546,7 @@ static int ah6_input(struct xfrm_state *x, struct sk_buff *skb) | |||
546 | ahash = ahp->ahash; | 546 | ahash = ahp->ahash; |
547 | 547 | ||
548 | nexthdr = ah->nexthdr; | 548 | nexthdr = ah->nexthdr; |
549 | ah_hlen = (ah->hdrlen + 2) << 2; | 549 | ah_hlen = ipv6_authlen(ah); |
550 | 550 | ||
551 | if (ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_full_len) && | 551 | if (ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_full_len) && |
552 | ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_trunc_len)) | 552 | ah_hlen != XFRM_ALIGN8(sizeof(*ah) + ahp->icv_trunc_len)) |
diff --git a/net/ipv6/exthdrs_core.c b/net/ipv6/exthdrs_core.c index 11a43ee4dd45..b358f1a4dd08 100644 --- a/net/ipv6/exthdrs_core.c +++ b/net/ipv6/exthdrs_core.c | |||
@@ -266,7 +266,7 @@ int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, | |||
266 | } else if (nexthdr == NEXTHDR_AUTH) { | 266 | } else if (nexthdr == NEXTHDR_AUTH) { |
267 | if (flags && (*flags & IP6_FH_F_AUTH) && (target < 0)) | 267 | if (flags && (*flags & IP6_FH_F_AUTH) && (target < 0)) |
268 | break; | 268 | break; |
269 | hdrlen = (hp->hdrlen + 2) << 2; | 269 | hdrlen = ipv6_authlen(hp); |
270 | } else | 270 | } else |
271 | hdrlen = ipv6_optlen(hp); | 271 | hdrlen = ipv6_optlen(hp); |
272 | 272 | ||
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index b80fde1bc005..3134fbb65d7f 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c | |||
@@ -416,7 +416,7 @@ __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw) | |||
416 | break; | 416 | break; |
417 | optlen = 8; | 417 | optlen = 8; |
418 | } else if (nexthdr == NEXTHDR_AUTH) { | 418 | } else if (nexthdr == NEXTHDR_AUTH) { |
419 | optlen = (hdr->hdrlen + 2) << 2; | 419 | optlen = ipv6_authlen(hdr); |
420 | } else { | 420 | } else { |
421 | optlen = ipv6_optlen(hdr); | 421 | optlen = ipv6_optlen(hdr); |
422 | } | 422 | } |
diff --git a/net/ipv6/netfilter/ip6t_ah.c b/net/ipv6/netfilter/ip6t_ah.c index 0228ff3636bb..4e15a14435e4 100644 --- a/net/ipv6/netfilter/ip6t_ah.c +++ b/net/ipv6/netfilter/ip6t_ah.c | |||
@@ -55,7 +55,7 @@ static bool ah_mt6(const struct sk_buff *skb, struct xt_action_param *par) | |||
55 | return false; | 55 | return false; |
56 | } | 56 | } |
57 | 57 | ||
58 | hdrlen = (ah->hdrlen + 2) << 2; | 58 | hdrlen = ipv6_authlen(ah); |
59 | 59 | ||
60 | pr_debug("IPv6 AH LEN %u %u ", hdrlen, ah->hdrlen); | 60 | pr_debug("IPv6 AH LEN %u %u ", hdrlen, ah->hdrlen); |
61 | pr_debug("RES %04X ", ah->reserved); | 61 | pr_debug("RES %04X ", ah->reserved); |
diff --git a/net/ipv6/netfilter/ip6t_ipv6header.c b/net/ipv6/netfilter/ip6t_ipv6header.c index fd439f88377f..0fc6326ef499 100644 --- a/net/ipv6/netfilter/ip6t_ipv6header.c +++ b/net/ipv6/netfilter/ip6t_ipv6header.c | |||
@@ -71,7 +71,7 @@ ipv6header_mt6(const struct sk_buff *skb, struct xt_action_param *par) | |||
71 | if (nexthdr == NEXTHDR_FRAGMENT) | 71 | if (nexthdr == NEXTHDR_FRAGMENT) |
72 | hdrlen = 8; | 72 | hdrlen = 8; |
73 | else if (nexthdr == NEXTHDR_AUTH) | 73 | else if (nexthdr == NEXTHDR_AUTH) |
74 | hdrlen = (hp->hdrlen + 2) << 2; | 74 | hdrlen = ipv6_authlen(hp); |
75 | else | 75 | else |
76 | hdrlen = ipv6_optlen(hp); | 76 | hdrlen = ipv6_optlen(hp); |
77 | 77 | ||
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 398e1df41406..0f82c150543b 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c | |||
@@ -414,7 +414,7 @@ find_prev_fhdr(struct sk_buff *skb, u8 *prevhdrp, int *prevhoff, int *fhoff) | |||
414 | if (skb_copy_bits(skb, start, &hdr, sizeof(hdr))) | 414 | if (skb_copy_bits(skb, start, &hdr, sizeof(hdr))) |
415 | BUG(); | 415 | BUG(); |
416 | if (nexthdr == NEXTHDR_AUTH) | 416 | if (nexthdr == NEXTHDR_AUTH) |
417 | hdrlen = (hdr.hdrlen+2)<<2; | 417 | hdrlen = ipv6_authlen(&hdr); |
418 | else | 418 | else |
419 | hdrlen = ipv6_optlen(&hdr); | 419 | hdrlen = ipv6_optlen(&hdr); |
420 | 420 | ||
diff --git a/net/ipv6/netfilter/nf_log_ipv6.c b/net/ipv6/netfilter/nf_log_ipv6.c index 549c51156d5d..f53bd8f01219 100644 --- a/net/ipv6/netfilter/nf_log_ipv6.c +++ b/net/ipv6/netfilter/nf_log_ipv6.c | |||
@@ -155,7 +155,7 @@ static void dump_ipv6_packet(struct net *net, struct nf_log_buf *m, | |||
155 | 155 | ||
156 | } | 156 | } |
157 | 157 | ||
158 | hdrlen = (hp->hdrlen+2)<<2; | 158 | hdrlen = ipv6_authlen(hp); |
159 | break; | 159 | break; |
160 | case IPPROTO_ESP: | 160 | case IPPROTO_ESP: |
161 | if (logflags & NF_LOG_IPOPT) { | 161 | if (logflags & NF_LOG_IPOPT) { |