diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-11-14 00:32:26 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:53:35 -0500 |
commit | 0148894223740da4818d7f4e6f92cbb5481a25b8 (patch) | |
tree | be37af4b8c3c81b45c7fff28ff7b6f09c78e2ef0 /net/ipv6 | |
parent | b24b8a247ff65c01b252025926fe564209fae4fc (diff) |
[IPV6]: Only set nfheader_len for top xfrm dst
We only need to set nfheader_len in the top xfrm dst. This is because
we only ever read the nfheader_len from the top xfrm dst.
It is also easier to count nfheader_len as part of header_len which
then lets us remove the ugly wrapper functions for incrementing and
decrementing header lengths in xfrm6_policy.c.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/ip6_output.c | 3 | ||||
-rw-r--r-- | net/ipv6/xfrm6_policy.c | 26 |
2 files changed, 6 insertions, 23 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 3bef30e4a23d..150615758fdc 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -1098,7 +1098,8 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, | |||
1098 | inet->cork.length = 0; | 1098 | inet->cork.length = 0; |
1099 | sk->sk_sndmsg_page = NULL; | 1099 | sk->sk_sndmsg_page = NULL; |
1100 | sk->sk_sndmsg_off = 0; | 1100 | sk->sk_sndmsg_off = 0; |
1101 | exthdrlen = rt->u.dst.header_len + (opt ? opt->opt_flen : 0); | 1101 | exthdrlen = rt->u.dst.header_len + (opt ? opt->opt_flen : 0) - |
1102 | rt->u.dst.nfheader_len; | ||
1102 | length += exthdrlen; | 1103 | length += exthdrlen; |
1103 | transhdrlen += exthdrlen; | 1104 | transhdrlen += exthdrlen; |
1104 | } else { | 1105 | } else { |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index b8e9eb445d74..3cad3e8dc4da 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -102,24 +102,6 @@ __xfrm6_bundle_addr_local(struct xfrm_state *x, struct in6_addr *addr) | |||
102 | (struct in6_addr*)&x->props.saddr; | 102 | (struct in6_addr*)&x->props.saddr; |
103 | } | 103 | } |
104 | 104 | ||
105 | static inline void | ||
106 | __xfrm6_bundle_len_inc(int *len, int *nflen, struct xfrm_state *x) | ||
107 | { | ||
108 | if (x->type->flags & XFRM_TYPE_NON_FRAGMENT) | ||
109 | *nflen += x->props.header_len; | ||
110 | else | ||
111 | *len += x->props.header_len; | ||
112 | } | ||
113 | |||
114 | static inline void | ||
115 | __xfrm6_bundle_len_dec(int *len, int *nflen, struct xfrm_state *x) | ||
116 | { | ||
117 | if (x->type->flags & XFRM_TYPE_NON_FRAGMENT) | ||
118 | *nflen -= x->props.header_len; | ||
119 | else | ||
120 | *len -= x->props.header_len; | ||
121 | } | ||
122 | |||
123 | /* Allocate chain of dst_entry's, attach known xfrm's, calculate | 105 | /* Allocate chain of dst_entry's, attach known xfrm's, calculate |
124 | * all the metrics... Shortly, bundle a bundle. | 106 | * all the metrics... Shortly, bundle a bundle. |
125 | */ | 107 | */ |
@@ -142,7 +124,6 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int | |||
142 | int i; | 124 | int i; |
143 | int err = 0; | 125 | int err = 0; |
144 | int header_len = 0; | 126 | int header_len = 0; |
145 | int nfheader_len = 0; | ||
146 | int trailer_len = 0; | 127 | int trailer_len = 0; |
147 | 128 | ||
148 | dst = dst_prev = NULL; | 129 | dst = dst_prev = NULL; |
@@ -175,7 +156,9 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int | |||
175 | dst1->next = dst_prev; | 156 | dst1->next = dst_prev; |
176 | dst_prev = dst1; | 157 | dst_prev = dst1; |
177 | 158 | ||
178 | __xfrm6_bundle_len_inc(&header_len, &nfheader_len, xfrm[i]); | 159 | if (xfrm[i]->type->flags & XFRM_TYPE_NON_FRAGMENT) |
160 | dst->nfheader_len += xfrm[i]->props.header_len; | ||
161 | header_len += xfrm[i]->props.header_len; | ||
179 | trailer_len += xfrm[i]->props.trailer_len; | 162 | trailer_len += xfrm[i]->props.trailer_len; |
180 | 163 | ||
181 | if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { | 164 | if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) { |
@@ -223,7 +206,6 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int | |||
223 | dst_prev->flags |= DST_HOST; | 206 | dst_prev->flags |= DST_HOST; |
224 | dst_prev->lastuse = jiffies; | 207 | dst_prev->lastuse = jiffies; |
225 | dst_prev->header_len = header_len; | 208 | dst_prev->header_len = header_len; |
226 | dst_prev->nfheader_len = nfheader_len; | ||
227 | dst_prev->trailer_len = trailer_len; | 209 | dst_prev->trailer_len = trailer_len; |
228 | memcpy(&dst_prev->metrics, &x->route->metrics, sizeof(dst_prev->metrics)); | 210 | memcpy(&dst_prev->metrics, &x->route->metrics, sizeof(dst_prev->metrics)); |
229 | 211 | ||
@@ -242,7 +224,7 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int | |||
242 | x->u.rt6.rt6i_src = rt0->rt6i_src; | 224 | x->u.rt6.rt6i_src = rt0->rt6i_src; |
243 | x->u.rt6.rt6i_idev = rt0->rt6i_idev; | 225 | x->u.rt6.rt6i_idev = rt0->rt6i_idev; |
244 | in6_dev_hold(rt0->rt6i_idev); | 226 | in6_dev_hold(rt0->rt6i_idev); |
245 | __xfrm6_bundle_len_dec(&header_len, &nfheader_len, x->u.dst.xfrm); | 227 | header_len -= x->u.dst.xfrm->props.header_len; |
246 | trailer_len -= x->u.dst.xfrm->props.trailer_len; | 228 | trailer_len -= x->u.dst.xfrm->props.trailer_len; |
247 | } | 229 | } |
248 | 230 | ||