diff --git a/patch/kernel-ipv6-ra-metric-sysctl.patch b/patch/kernel-ipv6-ra-metric-sysctl.patch new file mode 100644 index 000000000..28ea47445 --- /dev/null +++ b/patch/kernel-ipv6-ra-metric-sysctl.patch @@ -0,0 +1,103 @@ +Allow user to set ipv6 Router Advertisement(RA) metric. + +Linux kernel allows user configured metric on IPv4 default +routes learned via DHCP. For IPv6, default router is added +via RA message, where currently a fixed metric value 1024 +is applied. We should allow user to set ipv6 RA metric. + +Fix: +Add new field in ipv6_devconf for RA default route metric. + i.e accept_ra_defrtr_metric. +Add accept_ra_defrtr_metric as sysctl. +If accept_ra_defrtr_metric is set, then change metric on + default route, whenever new IPv6 RA is received. + +Note: Metric is changed on default route only when new IPv6 + RA is received. + +Signed-off-by: Praveen Chaudhary +Signed-off-by: Zhenggen Xu +diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h +index b9dfca5..9b70be7 100644 +--- a/include/linux/ipv6.h ++++ b/include/linux/ipv6.h +@@ -30,6 +30,7 @@ struct ipv6_devconf { + __s32 max_desync_factor; + __s32 max_addresses; + __s32 accept_ra_defrtr; ++ __u32 accept_ra_defrtr_metric; + __s32 accept_ra_min_hop_limit; + __s32 accept_ra_pinfo; + __s32 ignore_routes_with_linkdown; +diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h +index 8c27723..36d7097 100644 +--- a/include/uapi/linux/ipv6.h ++++ b/include/uapi/linux/ipv6.h +@@ -152,6 +152,7 @@ enum { + DEVCONF_MAX_ADDRESSES, + DEVCONF_FORCE_MLD_VERSION, + DEVCONF_ACCEPT_RA_DEFRTR, ++ DEVCONF_ACCEPT_RA_DEFRTR_METRIC, + DEVCONF_ACCEPT_RA_PINFO, + DEVCONF_ACCEPT_RA_RTR_PREF, + DEVCONF_RTR_PROBE_INTERVAL, +diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c +index 4ce7f91..529db12 100644 +--- a/net/ipv6/addrconf.c ++++ b/net/ipv6/addrconf.c +@@ -216,6 +216,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { + .max_desync_factor = MAX_DESYNC_FACTOR, + .max_addresses = IPV6_MAX_ADDRESSES, + .accept_ra_defrtr = 1, ++ .accept_ra_defrtr_metric = 0, + .accept_ra_from_local = 0, + .accept_ra_min_hop_limit= 1, + .accept_ra_pinfo = 1, +@@ -262,6 +263,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { + .max_desync_factor = MAX_DESYNC_FACTOR, + .max_addresses = IPV6_MAX_ADDRESSES, + .accept_ra_defrtr = 1, ++ .accept_ra_defrtr_metric = 0, + .accept_ra_from_local = 0, + .accept_ra_min_hop_limit= 1, + .accept_ra_pinfo = 1, +@@ -4951,6 +4953,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, + array[DEVCONF_MAX_DESYNC_FACTOR] = cnf->max_desync_factor; + array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses; + array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr; ++ array[DEVCONF_ACCEPT_RA_DEFRTR_METRIC] = cnf->accept_ra_defrtr_metric; + array[DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT] = cnf->accept_ra_min_hop_limit; + array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo; + #ifdef CONFIG_IPV6_ROUTER_PREF +@@ -5903,6 +5906,13 @@ static const struct ctl_table addrconf_sysctl[] = { + .proc_handler = proc_dointvec, + }, + { ++ .procname = "accept_ra_defrtr_metric", ++ .data = &ipv6_devconf.accept_ra_defrtr_metric, ++ .maxlen = sizeof(u32), ++ .mode = 0644, ++ .proc_handler = proc_douintvec, ++ }, ++ { + .procname = "accept_ra_min_hop_limit", + .data = &ipv6_devconf.accept_ra_min_hop_limit, + .maxlen = sizeof(int), +diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c +index 505d048..eb6f16f 100644 +--- a/net/ipv6/ndisc.c ++++ b/net/ipv6/ndisc.c +@@ -1279,8 +1279,12 @@ static void ndisc_router_discovery(struct sk_buff *skb) + rt->rt6i_flags = (rt->rt6i_flags & ~RTF_PREF_MASK) | RTF_PREF(pref); + } + +- if (rt) ++ if (rt) { + rt6_set_expires(rt, jiffies + (HZ * lifetime)); ++ /* Set metric as per ipv6 dev cnf */ ++ if (in6_dev->cnf.accept_ra_defrtr_metric) ++ rt->rt6i_metric = in6_dev->cnf.accept_ra_defrtr_metric; ++ } + if (in6_dev->cnf.accept_ra_min_hop_limit < 256 && + ra_msg->icmph.icmp6_hop_limit) { + if (in6_dev->cnf.accept_ra_min_hop_limit <= ra_msg->icmph.icmp6_hop_limit) { diff --git a/patch/series b/patch/series index 32f66c8fc..f3394c962 100755 --- a/patch/series +++ b/patch/series @@ -38,6 +38,7 @@ netlink-add-NLA_MIN_LEN.patch macsec-Netlink-support-of-XPN-cipher-suites-IEEE-802.patch Support-for-fullcone-nat.patch driver-ixgbe-external-phy.patch +kernel-ipv6-ra-metric-sysctl.patch # # This series applies on GIT commit 1451b36b2b0d62178e42f648d8a18131af18f7d8 # Tkernel-sched-core-fix-cgroup-fork-race.patch