| 1 |
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
|
| 2 |
index a0f6842..713c283 100644
|
| 3 |
--- a/Documentation/networking/ip-sysctl.txt
|
| 4 |
+++ b/Documentation/networking/ip-sysctl.txt
|
| 5 |
@@ -825,6 +825,15 @@ accept_redirects - BOOLEAN
|
| 6 |
Functional default: enabled if local forwarding is disabled.
|
| 7 |
disabled if local forwarding is enabled.
|
| 8 |
|
| 9 |
+accept_source_route - INTEGER
|
| 10 |
+ Accept source routing (routing extension header).
|
| 11 |
+
|
| 12 |
+ > 0: Accept routing header.
|
| 13 |
+ = 0: Accept only routing header type 2.
|
| 14 |
+ < 0: Do not accept routing header.
|
| 15 |
+
|
| 16 |
+ Default: 0
|
| 17 |
+
|
| 18 |
autoconf - BOOLEAN
|
| 19 |
Autoconfigure addresses using Prefix Information in Router
|
| 20 |
Advertisements.
|
| 21 |
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
|
| 22 |
index f824113..713eb5e 100644
|
| 23 |
--- a/include/linux/ipv6.h
|
| 24 |
+++ b/include/linux/ipv6.h
|
| 25 |
@@ -177,6 +177,7 @@ struct ipv6_devconf {
|
| 26 |
#endif
|
| 27 |
#endif
|
| 28 |
__s32 proxy_ndp;
|
| 29 |
+ __s32 accept_source_route;
|
| 30 |
void *sysctl;
|
| 31 |
};
|
| 32 |
|
| 33 |
@@ -205,6 +206,8 @@ enum {
|
| 34 |
DEVCONF_RTR_PROBE_INTERVAL,
|
| 35 |
DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN,
|
| 36 |
DEVCONF_PROXY_NDP,
|
| 37 |
+ __DEVCONF_OPTIMISTIC_DAD,
|
| 38 |
+ DEVCONF_ACCEPT_SOURCE_ROUTE,
|
| 39 |
DEVCONF_MAX
|
| 40 |
};
|
| 41 |
|
| 42 |
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
|
| 43 |
index 81480e6..6f34622 100644
|
| 44 |
--- a/include/linux/sysctl.h
|
| 45 |
+++ b/include/linux/sysctl.h
|
| 46 |
@@ -570,6 +570,7 @@ enum {
|
| 47 |
NET_IPV6_RTR_PROBE_INTERVAL=21,
|
| 48 |
NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN=22,
|
| 49 |
NET_IPV6_PROXY_NDP=23,
|
| 50 |
+ NET_IPV6_ACCEPT_SOURCE_ROUTE=25,
|
| 51 |
__NET_IPV6_MAX
|
| 52 |
};
|
| 53 |
|
| 54 |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
|
| 55 |
index 58cb669..f5af4ca 100644
|
| 56 |
--- a/net/ipv6/addrconf.c
|
| 57 |
+++ b/net/ipv6/addrconf.c
|
| 58 |
@@ -173,6 +173,7 @@ struct ipv6_devconf ipv6_devconf __read_mostly = {
|
| 59 |
#endif
|
| 60 |
#endif
|
| 61 |
.proxy_ndp = 0,
|
| 62 |
+ .accept_source_route = 0, /* we do not accept RH0 by default. */
|
| 63 |
};
|
| 64 |
|
| 65 |
static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
|
| 66 |
@@ -204,6 +205,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
|
| 67 |
#endif
|
| 68 |
#endif
|
| 69 |
.proxy_ndp = 0,
|
| 70 |
+ .accept_source_route = 0, /* we do not accept RH0 by default. */
|
| 71 |
};
|
| 72 |
|
| 73 |
/* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
|
| 74 |
@@ -3400,6 +3402,7 @@ static void inline ipv6_store_devconf(struct ipv6_devconf *cnf,
|
| 75 |
#endif
|
| 76 |
#endif
|
| 77 |
array[DEVCONF_PROXY_NDP] = cnf->proxy_ndp;
|
| 78 |
+ array[DEVCONF_ACCEPT_SOURCE_ROUTE] = cnf->accept_source_route;
|
| 79 |
}
|
| 80 |
|
| 81 |
static inline size_t inet6_if_nlmsg_size(void)
|
| 82 |
@@ -3920,6 +3923,14 @@ static struct addrconf_sysctl_table
|
| 83 |
.proc_handler = &proc_dointvec,
|
| 84 |
},
|
| 85 |
{
|
| 86 |
+ .ctl_name = NET_IPV6_ACCEPT_SOURCE_ROUTE,
|
| 87 |
+ .procname = "accept_source_route",
|
| 88 |
+ .data = &ipv6_devconf.accept_source_route,
|
| 89 |
+ .maxlen = sizeof(int),
|
| 90 |
+ .mode = 0644,
|
| 91 |
+ .proc_handler = &proc_dointvec,
|
| 92 |
+ },
|
| 93 |
+ {
|
| 94 |
.ctl_name = 0, /* sentinel */
|
| 95 |
}
|
| 96 |
},
|
| 97 |
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
|
| 98 |
index 0711f92..5fd7cf9 100644
|
| 99 |
--- a/net/ipv6/exthdrs.c
|
| 100 |
+++ b/net/ipv6/exthdrs.c
|
| 101 |
@@ -363,10 +363,27 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
|
| 102 |
struct inet6_skb_parm *opt = IP6CB(skb);
|
| 103 |
struct in6_addr *addr = NULL;
|
| 104 |
struct in6_addr daddr;
|
| 105 |
+ struct inet6_dev *idev;
|
| 106 |
int n, i;
|
| 107 |
-
|
| 108 |
struct ipv6_rt_hdr *hdr;
|
| 109 |
struct rt0_hdr *rthdr;
|
| 110 |
+ int accept_source_route = ipv6_devconf.accept_source_route;
|
| 111 |
+
|
| 112 |
+ if (accept_source_route < 0 ||
|
| 113 |
+ ((idev = in6_dev_get(skb->dev)) == NULL)) {
|
| 114 |
+ kfree_skb(skb);
|
| 115 |
+ return -1;
|
| 116 |
+ }
|
| 117 |
+ if (idev->cnf.accept_source_route < 0) {
|
| 118 |
+ in6_dev_put(idev);
|
| 119 |
+ kfree_skb(skb);
|
| 120 |
+ return -1;
|
| 121 |
+ }
|
| 122 |
+
|
| 123 |
+ if (accept_source_route > idev->cnf.accept_source_route)
|
| 124 |
+ accept_source_route = idev->cnf.accept_source_route;
|
| 125 |
+
|
| 126 |
+ in6_dev_put(idev);
|
| 127 |
|
| 128 |
if (!pskb_may_pull(skb, (skb->h.raw-skb->data)+8) ||
|
| 129 |
!pskb_may_pull(skb, (skb->h.raw-skb->data)+((skb->h.raw[1]+1)<<3))) {
|
| 130 |
@@ -378,6 +395,22 @@ static int ipv6_rthdr_rcv(struct sk_buff **skbp)
|
| 131 |
|
| 132 |
hdr = (struct ipv6_rt_hdr *) skb->h.raw;
|
| 133 |
|
| 134 |
+ switch (hdr->type) {
|
| 135 |
+#ifdef CONFIG_IPV6_MIP6
|
| 136 |
+ break;
|
| 137 |
+#endif
|
| 138 |
+ case IPV6_SRCRT_TYPE_0:
|
| 139 |
+ if (accept_source_route > 0)
|
| 140 |
+ break;
|
| 141 |
+ kfree_skb(skb);
|
| 142 |
+ return -1;
|
| 143 |
+ default:
|
| 144 |
+ IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
|
| 145 |
+ IPSTATS_MIB_INHDRERRORS);
|
| 146 |
+ icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw);
|
| 147 |
+ return -1;
|
| 148 |
+ }
|
| 149 |
+
|
| 150 |
if (ipv6_addr_is_multicast(&skb->nh.ipv6h->daddr) ||
|
| 151 |
skb->pkt_type != PACKET_HOST) {
|
| 152 |
IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
|
| 153 |
@@ -435,11 +468,6 @@ looped_back:
|
| 154 |
}
|
| 155 |
break;
|
| 156 |
#endif
|
| 157 |
- default:
|
| 158 |
- IP6_INC_STATS_BH(ip6_dst_idev(skb->dst),
|
| 159 |
- IPSTATS_MIB_INHDRERRORS);
|
| 160 |
- icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, (&hdr->type) - skb->nh.raw);
|
| 161 |
- return -1;
|
| 162 |
}
|
| 163 |
|
| 164 |
/*
|