diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-12 02:26:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-12 02:39:11 -0400 |
commit | 30f2a5f379d0b4b4e733df138a49e054ebf75ff8 (patch) | |
tree | ddd818a29e28e49b1916d3e9dba62c1272912f5f /net/ipv6/ndisc.c | |
parent | 1f42539d257af671d56d4bdbcf13aef31abff6ef (diff) |
ipv6: Export ndisc option parsing from ndisc.c
This is going to be used internally by the rt6 redirect code.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ndisc.c')
-rw-r--r-- | net/ipv6/ndisc.c | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 0fddd571400d..a3189baa9f4f 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -143,40 +143,8 @@ struct neigh_table nd_tbl = { | |||
143 | .gc_thresh3 = 1024, | 143 | .gc_thresh3 = 1024, |
144 | }; | 144 | }; |
145 | 145 | ||
146 | /* ND options */ | ||
147 | struct ndisc_options { | ||
148 | struct nd_opt_hdr *nd_opt_array[__ND_OPT_ARRAY_MAX]; | ||
149 | #ifdef CONFIG_IPV6_ROUTE_INFO | ||
150 | struct nd_opt_hdr *nd_opts_ri; | ||
151 | struct nd_opt_hdr *nd_opts_ri_end; | ||
152 | #endif | ||
153 | struct nd_opt_hdr *nd_useropts; | ||
154 | struct nd_opt_hdr *nd_useropts_end; | ||
155 | }; | ||
156 | |||
157 | #define nd_opts_src_lladdr nd_opt_array[ND_OPT_SOURCE_LL_ADDR] | ||
158 | #define nd_opts_tgt_lladdr nd_opt_array[ND_OPT_TARGET_LL_ADDR] | ||
159 | #define nd_opts_pi nd_opt_array[ND_OPT_PREFIX_INFO] | ||
160 | #define nd_opts_pi_end nd_opt_array[__ND_OPT_PREFIX_INFO_END] | ||
161 | #define nd_opts_rh nd_opt_array[ND_OPT_REDIRECT_HDR] | ||
162 | #define nd_opts_mtu nd_opt_array[ND_OPT_MTU] | ||
163 | |||
164 | #define NDISC_OPT_SPACE(len) (((len)+2+7)&~7) | 146 | #define NDISC_OPT_SPACE(len) (((len)+2+7)&~7) |
165 | 147 | ||
166 | /* | ||
167 | * Return the padding between the option length and the start of the | ||
168 | * link addr. Currently only IP-over-InfiniBand needs this, although | ||
169 | * if RFC 3831 IPv6-over-Fibre Channel is ever implemented it may | ||
170 | * also need a pad of 2. | ||
171 | */ | ||
172 | static int ndisc_addr_option_pad(unsigned short type) | ||
173 | { | ||
174 | switch (type) { | ||
175 | case ARPHRD_INFINIBAND: return 2; | ||
176 | default: return 0; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | static inline int ndisc_opt_addr_space(struct net_device *dev) | 148 | static inline int ndisc_opt_addr_space(struct net_device *dev) |
181 | { | 149 | { |
182 | return NDISC_OPT_SPACE(dev->addr_len + ndisc_addr_option_pad(dev->type)); | 150 | return NDISC_OPT_SPACE(dev->addr_len + ndisc_addr_option_pad(dev->type)); |
@@ -233,8 +201,8 @@ static struct nd_opt_hdr *ndisc_next_useropt(struct nd_opt_hdr *cur, | |||
233 | return cur <= end && ndisc_is_useropt(cur) ? cur : NULL; | 201 | return cur <= end && ndisc_is_useropt(cur) ? cur : NULL; |
234 | } | 202 | } |
235 | 203 | ||
236 | static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, | 204 | struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, |
237 | struct ndisc_options *ndopts) | 205 | struct ndisc_options *ndopts) |
238 | { | 206 | { |
239 | struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)opt; | 207 | struct nd_opt_hdr *nd_opt = (struct nd_opt_hdr *)opt; |
240 | 208 | ||
@@ -297,17 +265,6 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, | |||
297 | return ndopts; | 265 | return ndopts; |
298 | } | 266 | } |
299 | 267 | ||
300 | static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p, | ||
301 | struct net_device *dev) | ||
302 | { | ||
303 | u8 *lladdr = (u8 *)(p + 1); | ||
304 | int lladdrlen = p->nd_opt_len << 3; | ||
305 | int prepad = ndisc_addr_option_pad(dev->type); | ||
306 | if (lladdrlen != NDISC_OPT_SPACE(dev->addr_len + prepad)) | ||
307 | return NULL; | ||
308 | return lladdr + prepad; | ||
309 | } | ||
310 | |||
311 | int ndisc_mc_map(const struct in6_addr *addr, char *buf, struct net_device *dev, int dir) | 268 | int ndisc_mc_map(const struct in6_addr *addr, char *buf, struct net_device *dev, int dir) |
312 | { | 269 | { |
313 | switch (dev->type) { | 270 | switch (dev->type) { |