|
| 1 | +diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h |
| 2 | +index 8415bf1..7b15f19 100644 |
| 3 | +--- a/include/linux/ipv6.h |
| 4 | ++++ b/include/linux/ipv6.h |
| 5 | +@@ -31,6 +31,7 @@ struct ipv6_devconf { |
| 6 | + __s32 max_desync_factor; |
| 7 | + __s32 max_addresses; |
| 8 | + __s32 accept_ra_defrtr; |
| 9 | ++ __u32 accept_ra_defrtr_metric; |
| 10 | + __s32 accept_ra_min_hop_limit; |
| 11 | + __s32 accept_ra_pinfo; |
| 12 | + __s32 ignore_routes_with_linkdown; |
| 13 | +diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h |
| 14 | +index 9c0f4a9..44a7c35 100644 |
| 15 | +--- a/include/uapi/linux/ipv6.h |
| 16 | ++++ b/include/uapi/linux/ipv6.h |
| 17 | +@@ -154,6 +154,7 @@ enum { |
| 18 | + DEVCONF_MAX_ADDRESSES, |
| 19 | + DEVCONF_FORCE_MLD_VERSION, |
| 20 | + DEVCONF_ACCEPT_RA_DEFRTR, |
| 21 | ++ DEVCONF_ACCEPT_RA_DEFRTR_METRIC, |
| 22 | + DEVCONF_ACCEPT_RA_PINFO, |
| 23 | + DEVCONF_ACCEPT_RA_RTR_PREF, |
| 24 | + DEVCONF_RTR_PROBE_INTERVAL, |
| 25 | +diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c |
| 26 | +index 627cd24..fee2fc2 100644 |
| 27 | +--- a/net/ipv6/addrconf.c |
| 28 | ++++ b/net/ipv6/addrconf.c |
| 29 | +@@ -209,6 +209,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { |
| 30 | + .max_desync_factor = MAX_DESYNC_FACTOR, |
| 31 | + .max_addresses = IPV6_MAX_ADDRESSES, |
| 32 | + .accept_ra_defrtr = 1, |
| 33 | ++ .accept_ra_defrtr_metric = 0, |
| 34 | + .accept_ra_from_local = 0, |
| 35 | + .accept_ra_min_hop_limit= 1, |
| 36 | + .accept_ra_pinfo = 1, |
| 37 | +@@ -263,6 +264,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { |
| 38 | + .max_desync_factor = MAX_DESYNC_FACTOR, |
| 39 | + .max_addresses = IPV6_MAX_ADDRESSES, |
| 40 | + .accept_ra_defrtr = 1, |
| 41 | +++ .accept_ra_defrtr_metric = 0, |
| 42 | + .accept_ra_from_local = 0, |
| 43 | + .accept_ra_min_hop_limit= 1, |
| 44 | + .accept_ra_pinfo = 1, |
| 45 | +@@ -5199,6 +5201,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, |
| 46 | + array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor; |
| 47 | + array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses; |
| 48 | + array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr; |
| 49 | ++ array[DEVCONF_ACCEPT_RA_DEFRTR_METRIC] = cnf->accept_ra_defrtr_metric; |
| 50 | + array[DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT] = cnf->accept_ra_min_hop_limit; |
| 51 | + array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; |
| 52 | + #ifdef CONFIG_IPV6_ROUTER_PREF |
| 53 | +@@ -6348,6 +6351,13 @@ static const struct ctl_table addrconf_sysctl[] = { |
| 54 | + .proc_handler = proc_dointvec, |
| 55 | + }, |
| 56 | + { |
| 57 | ++ .procname = "accept_ra_defrtr_metric", |
| 58 | ++ .data = &ipv6_devconf.accept_ra_defrtr_metric, |
| 59 | ++ .maxlen = sizeof(u32), |
| 60 | ++ .mode = 0644, |
| 61 | ++ .proc_handler = proc_douintvec, |
| 62 | ++ }, |
| 63 | ++ { |
| 64 | + .procname = "accept_ra_min_hop_limit", |
| 65 | + .data = &ipv6_devconf.accept_ra_min_hop_limit, |
| 66 | + .maxlen = sizeof(int), |
| 67 | +diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c |
| 68 | +index 673a4a9..f52944a 100644 |
| 69 | +--- a/net/ipv6/ndisc.c |
| 70 | ++++ b/net/ipv6/ndisc.c |
| 71 | +@@ -1321,8 +1321,12 @@ static void ndisc_router_discovery(struct sk_buff *skb) |
| 72 | + rt->fib6_flags = (rt->fib6_flags & ~RTF_PREF_MASK) | RTF_PREF(pref); |
| 73 | + } |
| 74 | + |
| 75 | +- if (rt) |
| 76 | ++ if (rt) { |
| 77 | + fib6_set_expires(rt, jiffies + (HZ * lifetime)); |
| 78 | ++ /* Set metric as per ipv6 dev cnf */ |
| 79 | ++ if (in6_dev->cnf.accept_ra_defrtr_metric) |
| 80 | ++ rt->rt6i_metric = in6_dev->cnf.accept_ra_defrtr_metric; |
| 81 | ++ } |
| 82 | + if (in6_dev->cnf.accept_ra_min_hop_limit < 256 && |
| 83 | + ra_msg->icmph.icmp6_hop_limit) { |
| 84 | + if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit) { |
0 commit comments