Skip to content

Commit 930d6ff

Browse files
yoshfujidavem330
authored andcommitted
[IPV6]: ROUTE: Add accept_ra_rtr_pref sysctl.
Signed-off-by: YOSHIFUJI Hideaki <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2709725 commit 930d6ff

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

Documentation/networking/ip-sysctl.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,12 @@ accept_ra_pinfo - BOOLEAN
729729
Functional default: enabled if accept_ra is enabled.
730730
disabled if accept_ra is disabled.
731731

732+
accept_ra_rtr_pref - BOOLEAN
733+
Accept Router Preference in RA.
734+
735+
Functional default: enabled if accept_ra is enabled.
736+
disabled if accept_ra is disabled.
737+
732738
accept_redirects - BOOLEAN
733739
Accept Redirects.
734740

include/linux/ipv6.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ struct ipv6_devconf {
147147
__s32 max_addresses;
148148
__s32 accept_ra_defrtr;
149149
__s32 accept_ra_pinfo;
150+
#ifdef CONFIG_IPV6_ROUTER_PREF
151+
__s32 accept_ra_rtr_pref;
152+
#endif
150153
void *sysctl;
151154
};
152155

@@ -171,6 +174,7 @@ enum {
171174
DEVCONF_FORCE_MLD_VERSION,
172175
DEVCONF_ACCEPT_RA_DEFRTR,
173176
DEVCONF_ACCEPT_RA_PINFO,
177+
DEVCONF_ACCEPT_RA_RTR_PREF,
174178
DEVCONF_MAX
175179
};
176180

include/linux/sysctl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@ enum {
533533
NET_IPV6_FORCE_MLD_VERSION=17,
534534
NET_IPV6_ACCEPT_RA_DEFRTR=18,
535535
NET_IPV6_ACCEPT_RA_PINFO=19,
536+
NET_IPV6_ACCEPT_RA_RTR_PREF=20,
536537
__NET_IPV6_MAX
537538
};
538539

net/ipv6/addrconf.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ struct ipv6_devconf ipv6_devconf = {
167167
.max_addresses = IPV6_MAX_ADDRESSES,
168168
.accept_ra_defrtr = 1,
169169
.accept_ra_pinfo = 1,
170+
#ifdef CONFIG_IPV6_ROUTER_PREF
171+
.accept_ra_rtr_pref = 1,
172+
#endif
170173
};
171174

172175
static struct ipv6_devconf ipv6_devconf_dflt = {
@@ -190,6 +193,9 @@ static struct ipv6_devconf ipv6_devconf_dflt = {
190193
.max_addresses = IPV6_MAX_ADDRESSES,
191194
.accept_ra_defrtr = 1,
192195
.accept_ra_pinfo = 1,
196+
#ifdef CONFIG_IPV6_ROUTER_PREF
197+
.accept_ra_rtr_pref = 1,
198+
#endif
193199
};
194200

195201
/* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */
@@ -3122,6 +3128,9 @@ static void inline ipv6_store_devconf(struct ipv6_devconf *cnf,
31223128
array[DEVCONF_MAX_ADDRESSES] = cnf->max_addresses;
31233129
array[DEVCONF_ACCEPT_RA_DEFRTR] = cnf->accept_ra_defrtr;
31243130
array[DEVCONF_ACCEPT_RA_PINFO] = cnf->accept_ra_pinfo;
3131+
#ifdef CONFIG_IPV6_ROUTER_PREF
3132+
array[DEVCONF_ACCEPT_RA_RTR_PREF] = cnf->accept_ra_rtr_pref;
3133+
#endif
31253134
}
31263135

31273136
static int inet6_fill_ifinfo(struct sk_buff *skb, struct inet6_dev *idev,
@@ -3590,6 +3599,16 @@ static struct addrconf_sysctl_table
35903599
.mode = 0644,
35913600
.proc_handler = &proc_dointvec,
35923601
},
3602+
#ifdef CONFIG_IPV6_ROUTER_PREF
3603+
{
3604+
.ctl_name = NET_IPV6_ACCEPT_RA_RTR_PREF,
3605+
.procname = "accept_ra_rtr_pref",
3606+
.data = &ipv6_devconf.accept_ra_rtr_pref,
3607+
.maxlen = sizeof(int),
3608+
.mode = 0644,
3609+
.proc_handler = &proc_dointvec,
3610+
},
3611+
#endif
35933612
{
35943613
.ctl_name = 0, /* sentinel */
35953614
}

net/ipv6/ndisc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
10901090
#ifdef CONFIG_IPV6_ROUTER_PREF
10911091
pref = ra_msg->icmph.icmp6_router_pref;
10921092
/* 10b is handled as if it were 00b (medium) */
1093-
if (pref == ICMPV6_ROUTER_PREF_INVALID)
1093+
if (pref == ICMPV6_ROUTER_PREF_INVALID ||
1094+
in6_dev->cnf.accept_ra_rtr_pref)
10941095
pref = ICMPV6_ROUTER_PREF_MEDIUM;
10951096
#endif
10961097

0 commit comments

Comments
 (0)