Skip to content

Commit 59fbb3a

Browse files
Masahide NAKAMURADavid S. Miller
authored andcommitted
[IPV6] MIP6: Loadable module support for MIPv6.
This patch makes MIPv6 loadable module named "mip6". Here is a modprobe.conf(5) example to load it automatically when user application uses XFRM state for MIPv6: alias xfrm-type-10-43 mip6 alias xfrm-type-10-60 mip6 Some MIPv6 feature is not included by this modular, however, it should not be affected to other features like either IPsec or IPv6 with and without the patch. We may discuss XFRM, MH (RAW socket) and ancillary data/sockopt separately for future work. Loadable features: * MH receiving check (to send ICMP error back) * RO header parsing and building (i.e. RH2 and HAO in DSTOPTS) * XFRM policy/state database handling for RO These are NOT covered as loadable: * Home Address flags and its rule on source address selection * XFRM sub policy (depends on its own kernel option) * XFRM functions to receive RO as IPv6 extension header * MH sending/receiving through raw socket if user application opens it (since raw socket allows to do so) * RH2 sending as ancillary data * RH2 operation with setsockopt(2) Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 136ebf0 commit 59fbb3a

18 files changed

Lines changed: 88 additions & 46 deletions

‎include/linux/ipv6.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ struct inet6_skb_parm {
247247
__u16 lastopt;
248248
__u32 nhoff;
249249
__u16 flags;
250-
#ifdef CONFIG_IPV6_MIP6
250+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
251251
__u16 dsthao;
252252
#endif
253253

‎include/net/addrconf.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ extern int addrconf_set_dstaddr(void __user *arg);
6161
extern int ipv6_chk_addr(struct in6_addr *addr,
6262
struct net_device *dev,
6363
int strict);
64-
#ifdef CONFIG_IPV6_MIP6
64+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
6565
extern int ipv6_chk_home_addr(struct in6_addr *addr);
6666
#endif
6767
extern struct inet6_ifaddr * ipv6_get_ifaddr(struct in6_addr *addr,

‎include/net/mip6.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,4 @@ struct ip6_mh {
5454
#define IP6_MH_TYPE_BERROR 7 /* Binding Error */
5555
#define IP6_MH_TYPE_MAX IP6_MH_TYPE_BERROR
5656

57-
extern int mip6_init(void);
58-
extern void mip6_fini(void);
59-
extern int mip6_mh_filter(struct sock *sk, struct sk_buff *skb);
60-
6157
#endif

‎include/net/rawv6.h‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#ifdef __KERNEL__
55

6+
#include <net/protocol.h>
7+
68
#define RAWV6_HTABLE_SIZE MAX_INET_PROTOS
79
extern struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE];
810
extern rwlock_t raw_v6_lock;
@@ -23,6 +25,13 @@ extern void rawv6_err(struct sock *sk,
2325
int type, int code,
2426
int offset, __be32 info);
2527

28+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
29+
int rawv6_mh_filter_register(int (*filter)(struct sock *sock,
30+
struct sk_buff *skb));
31+
int rawv6_mh_filter_unregister(int (*filter)(struct sock *sock,
32+
struct sk_buff *skb));
33+
#endif
34+
2635
#endif
2736

2837
#endif

‎net/ipv6/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ config INET6_IPCOMP
109109
If unsure, say Y.
110110

111111
config IPV6_MIP6
112-
bool "IPv6: Mobility (EXPERIMENTAL)"
112+
tristate "IPv6: Mobility (EXPERIMENTAL)"
113113
depends on IPV6 && EXPERIMENTAL
114114
select XFRM
115115
---help---

‎net/ipv6/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ ipv6-$(CONFIG_XFRM) += xfrm6_policy.o xfrm6_state.o xfrm6_input.o \
1414
xfrm6_output.o
1515
ipv6-$(CONFIG_NETFILTER) += netfilter.o
1616
ipv6-$(CONFIG_IPV6_MULTIPLE_TABLES) += fib6_rules.o
17-
ipv6-$(CONFIG_IPV6_MIP6) += mip6.o
1817
ipv6-$(CONFIG_PROC_FS) += proc.o
1918

2019
ipv6-objs += $(ipv6-y)
@@ -28,6 +27,7 @@ obj-$(CONFIG_INET6_XFRM_MODE_TRANSPORT) += xfrm6_mode_transport.o
2827
obj-$(CONFIG_INET6_XFRM_MODE_TUNNEL) += xfrm6_mode_tunnel.o
2928
obj-$(CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION) += xfrm6_mode_ro.o
3029
obj-$(CONFIG_INET6_XFRM_MODE_BEET) += xfrm6_mode_beet.o
30+
obj-$(CONFIG_IPV6_MIP6) += mip6.o
3131
obj-$(CONFIG_NETFILTER) += netfilter/
3232

3333
obj-$(CONFIG_IPV6_SIT) += sit.o

‎net/ipv6/addrconf.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
10341034
}
10351035

10361036
/* Rule 4: Prefer home address */
1037-
#ifdef CONFIG_IPV6_MIP6
1037+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
10381038
if (hiscore.rule < 4) {
10391039
if (ifa_result->flags & IFA_F_HOMEADDRESS)
10401040
hiscore.attrs |= IPV6_SADDR_SCORE_HOA;
@@ -2835,7 +2835,7 @@ void if6_proc_exit(void)
28352835
}
28362836
#endif /* CONFIG_PROC_FS */
28372837

2838-
#ifdef CONFIG_IPV6_MIP6
2838+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
28392839
/* Check if address is a home address configured on any interface. */
28402840
int ipv6_chk_home_addr(struct in6_addr *addr)
28412841
{

‎net/ipv6/af_inet6.c‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@
5858
#ifdef CONFIG_IPV6_TUNNEL
5959
#include <net/ip6_tunnel.h>
6060
#endif
61-
#ifdef CONFIG_IPV6_MIP6
62-
#include <net/mip6.h>
63-
#endif
6461

6562
#include <asm/uaccess.h>
6663
#include <asm/system.h>
@@ -853,9 +850,6 @@ static int __init inet6_init(void)
853850
ipv6_frag_init();
854851
ipv6_nodata_init();
855852
ipv6_destopt_init();
856-
#ifdef CONFIG_IPV6_MIP6
857-
mip6_init();
858-
#endif
859853

860854
/* Init v6 transport protocols. */
861855
udpv6_init();
@@ -921,9 +915,7 @@ static void __exit inet6_exit(void)
921915

922916
/* Cleanup code parts. */
923917
ipv6_packet_cleanup();
924-
#ifdef CONFIG_IPV6_MIP6
925-
mip6_fini();
926-
#endif
918+
927919
addrconf_cleanup();
928920
ip6_flowlabel_cleanup();
929921
ip6_route_cleanup();

‎net/ipv6/ah6.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int zero_out_mutable_opts(struct ipv6_opt_hdr *opthdr)
7474
return 0;
7575
}
7676

77-
#ifdef CONFIG_IPV6_MIP6
77+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
7878
/**
7979
* ipv6_rearrange_destopt - rearrange IPv6 destination options header
8080
* @iph: IPv6 header
@@ -228,7 +228,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
228228
u8 nexthdr;
229229
char tmp_base[8];
230230
struct {
231-
#ifdef CONFIG_IPV6_MIP6
231+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
232232
struct in6_addr saddr;
233233
#endif
234234
struct in6_addr daddr;
@@ -255,7 +255,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
255255
err = -ENOMEM;
256256
goto error;
257257
}
258-
#ifdef CONFIG_IPV6_MIP6
258+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
259259
memcpy(tmp_ext, &top_iph->saddr, extlen);
260260
#else
261261
memcpy(tmp_ext, &top_iph->daddr, extlen);
@@ -294,7 +294,7 @@ static int ah6_output(struct xfrm_state *x, struct sk_buff *skb)
294294

295295
memcpy(top_iph, tmp_base, sizeof(tmp_base));
296296
if (tmp_ext) {
297-
#ifdef CONFIG_IPV6_MIP6
297+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
298298
memcpy(&top_iph->saddr, tmp_ext, extlen);
299299
#else
300300
memcpy(&top_iph->daddr, tmp_ext, extlen);

‎net/ipv6/datagram.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
658658

659659
switch (rthdr->type) {
660660
case IPV6_SRCRT_TYPE_0:
661-
#ifdef CONFIG_IPV6_MIP6
661+
#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
662662
case IPV6_SRCRT_TYPE_2:
663663
#endif
664664
break;

0 commit comments

Comments
 (0)