diff options
author | Florian Westphal <fw@strlen.de> | 2019-04-16 10:44:39 -0400 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2019-04-23 01:42:20 -0400 |
commit | c53ac41e3720926301c623d6682bb87ce992a3b3 (patch) | |
tree | 8b2e8e306321f3d305e705d5e30f8f9073e8a5dd /net/ipv6 | |
parent | 2e8b4aa816eaaf480fe68b1086614259caf1bf3c (diff) |
xfrm: remove decode_session indirection from afinfo_policy
No external dependencies, might as well handle this directly.
xfrm_afinfo_policy is now 40 bytes on x86_64.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/xfrm6_policy.c | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 358e834fedce..699e0730ce8e 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -22,9 +22,6 @@ | |||
22 | #include <net/ipv6.h> | 22 | #include <net/ipv6.h> |
23 | #include <net/ip6_route.h> | 23 | #include <net/ip6_route.h> |
24 | #include <net/l3mdev.h> | 24 | #include <net/l3mdev.h> |
25 | #if IS_ENABLED(CONFIG_IPV6_MIP6) | ||
26 | #include <net/mip6.h> | ||
27 | #endif | ||
28 | 25 | ||
29 | static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, int oif, | 26 | static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, int oif, |
30 | const xfrm_address_t *saddr, | 27 | const xfrm_address_t *saddr, |
@@ -100,108 +97,6 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, | |||
100 | return 0; | 97 | return 0; |
101 | } | 98 | } |
102 | 99 | ||
103 | static inline void | ||
104 | _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse) | ||
105 | { | ||
106 | struct flowi6 *fl6 = &fl->u.ip6; | ||
107 | int onlyproto = 0; | ||
108 | const struct ipv6hdr *hdr = ipv6_hdr(skb); | ||
109 | u32 offset = sizeof(*hdr); | ||
110 | struct ipv6_opt_hdr *exthdr; | ||
111 | const unsigned char *nh = skb_network_header(skb); | ||
112 | u16 nhoff = IP6CB(skb)->nhoff; | ||
113 | int oif = 0; | ||
114 | u8 nexthdr; | ||
115 | |||
116 | if (!nhoff) | ||
117 | nhoff = offsetof(struct ipv6hdr, nexthdr); | ||
118 | |||
119 | nexthdr = nh[nhoff]; | ||
120 | |||
121 | if (skb_dst(skb)) | ||
122 | oif = skb_dst(skb)->dev->ifindex; | ||
123 | |||
124 | memset(fl6, 0, sizeof(struct flowi6)); | ||
125 | fl6->flowi6_mark = skb->mark; | ||
126 | fl6->flowi6_oif = reverse ? skb->skb_iif : oif; | ||
127 | |||
128 | fl6->daddr = reverse ? hdr->saddr : hdr->daddr; | ||
129 | fl6->saddr = reverse ? hdr->daddr : hdr->saddr; | ||
130 | |||
131 | while (nh + offset + sizeof(*exthdr) < skb->data || | ||
132 | pskb_may_pull(skb, nh + offset + sizeof(*exthdr) - skb->data)) { | ||
133 | nh = skb_network_header(skb); | ||
134 | exthdr = (struct ipv6_opt_hdr *)(nh + offset); | ||
135 | |||
136 | switch (nexthdr) { | ||
137 | case NEXTHDR_FRAGMENT: | ||
138 | onlyproto = 1; | ||
139 | /* fall through */ | ||
140 | case NEXTHDR_ROUTING: | ||
141 | case NEXTHDR_HOP: | ||
142 | case NEXTHDR_DEST: | ||
143 | offset += ipv6_optlen(exthdr); | ||
144 | nexthdr = exthdr->nexthdr; | ||
145 | exthdr = (struct ipv6_opt_hdr *)(nh + offset); | ||
146 | break; | ||
147 | |||
148 | case IPPROTO_UDP: | ||
149 | case IPPROTO_UDPLITE: | ||
150 | case IPPROTO_TCP: | ||
151 | case IPPROTO_SCTP: | ||
152 | case IPPROTO_DCCP: | ||
153 | if (!onlyproto && (nh + offset + 4 < skb->data || | ||
154 | pskb_may_pull(skb, nh + offset + 4 - skb->data))) { | ||
155 | __be16 *ports; | ||
156 | |||
157 | nh = skb_network_header(skb); | ||
158 | ports = (__be16 *)(nh + offset); | ||
159 | fl6->fl6_sport = ports[!!reverse]; | ||
160 | fl6->fl6_dport = ports[!reverse]; | ||
161 | } | ||
162 | fl6->flowi6_proto = nexthdr; | ||
163 | return; | ||
164 | |||
165 | case IPPROTO_ICMPV6: | ||
166 | if (!onlyproto && (nh + offset + 2 < skb->data || | ||
167 | pskb_may_pull(skb, nh + offset + 2 - skb->data))) { | ||
168 | u8 *icmp; | ||
169 | |||
170 | nh = skb_network_header(skb); | ||
171 | icmp = (u8 *)(nh + offset); | ||
172 | fl6->fl6_icmp_type = icmp[0]; | ||
173 | fl6->fl6_icmp_code = icmp[1]; | ||
174 | } | ||
175 | fl6->flowi6_proto = nexthdr; | ||
176 | return; | ||
177 | |||
178 | #if IS_ENABLED(CONFIG_IPV6_MIP6) | ||
179 | case IPPROTO_MH: | ||
180 | offset += ipv6_optlen(exthdr); | ||
181 | if (!onlyproto && (nh + offset + 3 < skb->data || | ||
182 | pskb_may_pull(skb, nh + offset + 3 - skb->data))) { | ||
183 | struct ip6_mh *mh; | ||
184 | |||
185 | nh = skb_network_header(skb); | ||
186 | mh = (struct ip6_mh *)(nh + offset); | ||
187 | fl6->fl6_mh_type = mh->ip6mh_type; | ||
188 | } | ||
189 | fl6->flowi6_proto = nexthdr; | ||
190 | return; | ||
191 | #endif | ||
192 | |||
193 | /* XXX Why are there these headers? */ | ||
194 | case IPPROTO_AH: | ||
195 | case IPPROTO_ESP: | ||
196 | case IPPROTO_COMP: | ||
197 | default: | ||
198 | fl6->fl6_ipsec_spi = 0; | ||
199 | fl6->flowi6_proto = nexthdr; | ||
200 | return; | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | |||
205 | static void xfrm6_update_pmtu(struct dst_entry *dst, struct sock *sk, | 100 | static void xfrm6_update_pmtu(struct dst_entry *dst, struct sock *sk, |
206 | struct sk_buff *skb, u32 mtu) | 101 | struct sk_buff *skb, u32 mtu) |
207 | { | 102 | { |
@@ -273,7 +168,6 @@ static const struct xfrm_policy_afinfo xfrm6_policy_afinfo = { | |||
273 | .dst_ops = &xfrm6_dst_ops_template, | 168 | .dst_ops = &xfrm6_dst_ops_template, |
274 | .dst_lookup = xfrm6_dst_lookup, | 169 | .dst_lookup = xfrm6_dst_lookup, |
275 | .get_saddr = xfrm6_get_saddr, | 170 | .get_saddr = xfrm6_get_saddr, |
276 | .decode_session = _decode_session6, | ||
277 | .fill_dst = xfrm6_fill_dst, | 171 | .fill_dst = xfrm6_fill_dst, |
278 | .blackhole_route = ip6_blackhole_route, | 172 | .blackhole_route = ip6_blackhole_route, |
279 | }; | 173 | }; |