[PATCH v4 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu Reviewed-by: David Ahern Changes in v1. 1.) Correct the call to rt6_add_dflt_router. Changes in v2. 1.) Replace accept_ra_defrtr_metric to ra_defrtr_metric. 2.) Change Type to __u32 instead of __s32. 3.) Change description in Documentation/networking/ip-sysctl.rst. 4.) Use proc_douintvec instead of proc_dointvec. 5.) Code style in ndisc_router_discovery(). 6.) Change Type to u32 instead of unsigned int. Changes in v3: 1.) Removed '---' and '```' from description. 2.) Remove stray ' after accept_ra_defrtr. 3.) Fix tab in net/ipv6/addrconf.c. Changes in v4: 1.) Remove special case of 0 and use IP6_RT_PRIO_USER as default. 2.) Do not allow 0. 3.) Change Documentation accordingly. 4.) Remove extra brackets and compare with zero in ndisc_router_discovery(). 5.) Remove compare with zero in rt6_add_dflt_router(). Logs: For IPv4: Config in etc/network/interfaces: auto eth0 iface eth0 inet dhcp metric 4261413864 IPv4 Kernel Route Table: $ ip route list default via 172.21.47.1 dev eth0 metric 4261413864 FRR Table, if a static route is configured: [In real scenario, it is useful to prefer BGP learned default route over DHCPv4 default route.] Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m i.e. User can prefer Default Router learned via Routing Protocol in IPv4. Similar behavior is not possible for IPv6, without this fix. After fix [for IPv6]: sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.ra_defrtr_metric=1996489705 IP monitor: [When IPv6 RA is received] default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 pref high Kernel IPv6 routing table $ ip -6 route list default via fe80::be16:65ff:feb3:ce8e dev eth0 proto ra metric 1996489705 expires 21sec hoplimit 64 pref high FRR Table, if a static route is configured: [In real scenario, it is useful to prefer BGP learned default route over IPv6 RA default route.] Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::xx16::feb3:ce8e, eth0, 6d07h43m If the metric is changed later, the effect will be seen only when next IPv6 RA is received, because the default route must be fully controlled by RA msg. Below metric is changed from 1996489705 to 1996489704. $ sudo sysctl -w net.ipv6.conf.eth0.ra_defrtr_metric=1996489704 net.ipv6.conf.eth0.ra_defrtr_metric = 1996489704 IP monitor: [On next IPv6 RA msg, Kernel deletes prev route and installs new route with updated metric] Deleted default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 expires 3sec hoplimit 64 pref high default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489704 pref high --- Documentation/networking/ip-sysctl.rst | 10 ++ include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 11 +++ net/ipv6/ndisc.c | 12 net/ipv6/route.c | 5 +++-- 8 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index dd2b12a32b73..0e51ddd9a2f1 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1871,6 +1871,16 @@ accept_ra_defrtr - BOOLEAN - enabled if accept_ra is enabled. - disabled if accept_ra is disabled. +ra_defrtr_metric - UNSIGNED INTEGER + Route metric for default route learned in Router Advertisement. This value + will be assigned as metric for the default route learned via IPv6 Router + Advertisement. Takes affect only if accept_ra_defrtr is enabled. + + Possible values: + 1 to 0x + + Default: IP6_RT_PRIO_USER i.e. 1024. + accept_ra_from_local - BOOLEAN Accept RA with source-address that is found on local machine if the RA is otherwise proper and able to be accepted. diff --g
Re: [PATCH v3 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
> On Jan 23, 2021, at 5:13 PM, David Ahern wrote: > > On 1/23/21 1:00 PM, Jakub Kicinski wrote: >> On Fri, 22 Jan 2021 22:16:41 -0700 David Ahern wrote: >>> On 1/22/21 9:02 PM, Maciej Żenczykowski wrote: Why can't we get rid of the special case for 0 and simply make 1024 the default value? >>> >>> That would work too. >> >> Should we drop it then? Easier to bring it back than to change the >> interpretation later. It doesn't seem to serve any clear purpose right >> now. >> >> (Praveen if you post v4 please take a look at the checkpatch --strict >> warnings and address the ones which make sense, e.g. drop the brackets >> around comparisons, those are just noise, basic grasp of C operator >> precedence can be assumed in readers of kernel code). >> > > let's do a v4. > > Praveen: set the initial value to IP6_RT_PRIO_USER, do not allow 0, > remove the checks on value and don't forget to update documentation. > Sure, I will respin V4, with above mentioned changes. Also, I will address checkpatch --strict warnings. I wanted to set initial value to IP6_RT_PRIO_USER in v1, but avoided till review for 2 simple coding reasons: 1.) IP6_RT_PRIO_USER must be exposed in net/ipv6/addrconf.c by including include/uapi/linux/ipv6_route.h. 2.) If rt6_add_dflt_router() will be called from other files in future, IP6_RT_PRIO_USER should be included in all those files as well, because caller will pass most probably default value. > Oh and cc me on the next otherwise the review depends on me finding time > to scan netdev. Sure, I will cc you and will add “Reviewed by” as well. I will also send you the lkml link to v4. Thanks Jakub and you for reviewing this over the weekend.
Re: [PATCH v2 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
> On Jan 19, 2021, at 8:22 PM, David Ahern wrote: > > On 1/19/21 3:17 PM, praveen chaudhary wrote: >>>> >>>> For IPv4: >>>> >>>> >>>> Config in etc/network/interfaces >>>> >>>> ``` >>>> auto eth0 >>>> iface eth0 inet dhcp >>>> metric 4261413864 >>> >>> how does that work for IPv4? Is the metric passed to the dhclient and it >>> inserts the route with the given metric or is a dhclient script used to >>> replace the route after insert? >>> >>> >> >> Yes, DHCP client picks config under “iface eth0 inet dhcp” line and if >> metric is configured, then it adds the metric for all added routes. > > As I recall ifupdown{2} forks dhclient as a process to handle dhcp > config, and I believe there is a script that handles adding the default > route with metric. Meaning ... it is not comparable to an RA. > I hope, we both will agree that a fixed metric value on default route learned via RA restricts Network Administrators today. And such issues hinder the deployment of IPv6 only networks. So if we agree that in future we may need to allow a configurable value for metric then this fix makes good sense. BTW, kindly let me know if there is a better way to configure this metric. I think, sysctl is the only way. >> >> Thanks a lot again for spending time for this Review, >> This feature will help SONiC OS [and others Linux flavors] for better IPv6 >> support, so thanks again. > > I think SONiC is an abomination, so that is definitely not the > motivation for my reviews. :-) > Trying to make things better day by day. That is the only solace for Software Engineers :-). I really appreciate for your time to review this patch. Cheers.
Re: [PATCH v2 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
> On Jan 16, 2021, at 9:13 AM, David Ahern wrote: > > On 1/15/21 1:02 AM, Praveen Chaudhary wrote: >> For IPv4, default route is learned via DHCPv4 and user is allowed to change >> metric using config etc/network/interfaces. But for IPv6, default route can >> be learned via RA, for which, currently a fixed metric value 1024 is used. >> >> Ideally, user should be able to configure metric on default route for IPv6 >> similar to IPv4. This fix adds sysctl for the same. >> >> Signed-off-by: Praveen Chaudhary >> Signed-off-by: Zhenggen Xu >> >> Changes in v1. >> --- > > your trying to be too fancy in the log messages; everything after this > first '---' is dropped. Just Remove all of the '---' lines and '```' tags. > Removed all ‘—‘ and ‘```’ in v3. >> 1.) Correct the call to rt6_add_dflt_router. >> --- >> >> Changes in v2. >> [Refer: lkml.org/lkml/2021/1/14/1400] >> --- >> 1.) Replace accept_ra_defrtr_metric to ra_defrtr_metric. >> 2.) Change Type to __u32 instead of __s32. >> 3.) Change description in Documentation/networking/ip-sysctl.rst. >> 4.) Use proc_douintvec instead of proc_dointvec. >> 5.) Code style in ndisc_router_discovery(). >> 6.) Change Type to u32 instead of unsigned int. >> --- >> >> Logs: >> >> For IPv4: >> >> >> Config in etc/network/interfaces >> >> ``` >> auto eth0 >> iface eth0 inet dhcp >>metric 4261413864 > > how does that work for IPv4? Is the metric passed to the dhclient and it > inserts the route with the given metric or is a dhclient script used to > replace the route after insert? > > Yes, DHCP client picks config under “iface eth0 inet dhcp” line and if metric is configured, then it adds the metric for all added routes. >> diff --git a/Documentation/networking/ip-sysctl.rst >> b/Documentation/networking/ip-sysctl.rst >> index dd2b12a32b73..c4b8d4b8d213 100644 >> --- a/Documentation/networking/ip-sysctl.rst >> +++ b/Documentation/networking/ip-sysctl.rst >> @@ -1871,6 +1871,18 @@ accept_ra_defrtr - BOOLEAN >> - enabled if accept_ra is enabled. >> - disabled if accept_ra is disabled. >> >> +ra_defrtr_metric - INTEGER >> +Route metric for default route learned in Router Advertisement. This >> value >> +will be assigned as metric for the default route learned via IPv6 Router >> +Advertisement. Takes affect only if accept_ra_defrtr' is enabled. > > stray ' after accept_ra_defrtr > Removed. >> + >> +Possible values are: >> +0: >> +default value will be used for route metric >> +i.e. IP6_RT_PRIO_USER 1024. >> +1 to 0x: >> +current value will be used for route metric. >> + >> accept_ra_from_local - BOOLEAN >> Accept RA with source-address that is found on local machine >> if the RA is otherwise proper and able to be accepted. > > > >> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c >> index eff2cacd5209..b13d3213e58f 100644 >> --- a/net/ipv6/addrconf.c >> +++ b/net/ipv6/addrconf.c >> @@ -205,6 +205,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { >> .max_desync_factor = MAX_DESYNC_FACTOR, >> .max_addresses = IPV6_MAX_ADDRESSES, >> .accept_ra_defrtr = 1, >> +.ra_defrtr_metric = 0, > > make the the '=' align column wise with the existing entries; seems like > your new line is missing a tab Fixed. > >> .accept_ra_from_local = 0, >> .accept_ra_min_hop_limit= 1, >> .accept_ra_pinfo= 1, >> @@ -260,6 +261,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, >> +.ra_defrtr_metric = 0, > > same here Fixed. > >> .accept_ra_from_local = 0, >> .accept_ra_min_hop_limit= 1, >> .accept_ra_pinfo= 1, >> @@ -5475,6 +5477,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_DEFRT
[PATCH v3 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu Changes in v1. 1.) Correct the call to rt6_add_dflt_router. Changes in v2. 1.) Replace accept_ra_defrtr_metric to ra_defrtr_metric. 2.) Change Type to __u32 instead of __s32. 3.) Change description in Documentation/networking/ip-sysctl.rst. 4.) Use proc_douintvec instead of proc_dointvec. 5.) Code style in ndisc_router_discovery(). 6.) Change Type to u32 instead of unsigned int. Changes in v3: 1.) Removed '---' and '```' from description. 2.) Remove stray ' after accept_ra_defrtr. 3.) Fix tab in net/ipv6/addrconf.c. Logs: For IPv4: Config in etc/network/interfaces: auto eth0 iface eth0 inet dhcp metric 4261413864 IPv4 Kernel Route Table: $ ip route list default via 172.21.47.1 dev eth0 metric 4261413864 FRR Table, if a static route is configured: [In real scenario, it is useful to prefer BGP learned default route over DHCPv4 default route.] Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m i.e. User can prefer Default Router learned via Routing Protocol in IPv4. Similar behavior is not possible for IPv6, without this fix. After fix [for IPv6]: sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.ra_defrtr_metric=1996489705 IP monitor: [When IPv6 RA is received] default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 pref high Kernel IPv6 routing table $ ip -6 route list default via fe80::be16:65ff:feb3:ce8e dev eth0 proto ra metric 1996489705 expires 21sec hoplimit 64 pref high FRR Table, if a static route is configured: [In real scenario, it is useful to prefer BGP learned default route over IPv6 RA default route.] Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::xx16::feb3:ce8e, eth0, 6d07h43m If the metric is changed later, the effect will be seen only when next IPv6 RA is received, because the default route must be fully controlled by RA msg. Below metric is changed from 1996489705 to 1996489704. $ sudo sysctl -w net.ipv6.conf.eth0.ra_defrtr_metric=1996489704 net.ipv6.conf.eth0.ra_defrtr_metric = 1996489704 IP monitor: [On next IPv6 RA msg, Kernel deletes prev route and installs new route with updated metric] Deleted default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 expires 3sec hoplimit 64 pref high default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489704 pref high --- Documentation/networking/ip-sysctl.rst | 12 include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 14 ++ net/ipv6/route.c | 5 +++-- 8 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index dd2b12a32b73..6a644e794605 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1871,6 +1871,18 @@ accept_ra_defrtr - BOOLEAN - enabled if accept_ra is enabled. - disabled if accept_ra is disabled. +ra_defrtr_metric - INTEGER + Route metric for default route learned in Router Advertisement. This value + will be assigned as metric for the default route learned via IPv6 Router + Advertisement. Takes affect only if accept_ra_defrtr is enabled. + + Possible values are: + 0: + default value will be used for route metric + i.e. IP6_RT_PRIO_USER 1024. + 1 to 0x: + current value will be used for route metric. + accept_ra_from_local - BOOLEAN Accept RA with source-address that is found on local machine if the RA is otherwise proper and able to be accepted. diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index dda61d150a13..9d1f29f0c512 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@
[PATCH v2 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu Changes in v1. --- 1.) Correct the call to rt6_add_dflt_router. --- Changes in v2. [Ref: lkml/2021/1/14/1400] --- 1.) Replace accept_ra_defrtr_metric to ra_defrtr_metric. 2.) Change Type to __u32 instead of __s32. 3.) Change description in Documentation/networking/ip-sysctl.rst. 4.) Use proc_douintvec instead of proc_dointvec. 5.) Code style in ndisc_router_discovery(). 6.) Change Type to u32 instead of unsigned int. --- Reported-by: kernel test robot Logs: For IPv4: Config in etc/network/interfaces ``` auto eth0 iface eth0 inet dhcp metric 4261413864 ``` IPv4 Kernel Route Table: ``` $ ip route list default via 172.21.47.1 dev eth0 metric 4261413864 ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over DHCPv4 default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m ``` ***i.e. User can prefer Default Router learned via Routing Protocol in IPv4.*** ***Similar behavior is not possible for IPv6, without this fix.*** After fix [for IPv6]: ``` sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.ra_defrtr_metric=1996489705 ``` IP monitor: [When IPv6 RA is received] ``` default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 pref high ``` Kernel IPv6 routing table ``` $ ip -6 route list default via fe80::be16:65ff:feb3:ce8e dev eth0 proto ra metric 1996489705 expires 21sec hoplimit 64 pref high ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over IPv6 RA default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::xx16::feb3:ce8e, eth0, 6d07h43m ``` If the metric is changed later, the effect will be seen only when next IPv6 RA is received, because the default route must be fully controlled by RA msg. Below metric is changed from 1996489705 to 1996489704. ``` $ sudo sysctl -w net.ipv6.conf.eth0.ra_defrtr_metric=1996489704 net.ipv6.conf.eth0.ra_defrtr_metric = 1996489704 ``` IP monitor: [On next IPv6 RA msg, Kernel deletes prev route and installs new route with updated metric] ``` Deleted default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 expires 3sec hoplimit 64 pref high default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489704 pref high ``` --- Documentation/networking/ip-sysctl.rst | 12 include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 14 ++ net/ipv6/route.c | 5 +++-- 8 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index dd2b12a32b73..c4b8d4b8d213 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1871,6 +1871,18 @@ accept_ra_defrtr - BOOLEAN - enabled if accept_ra is enabled. - disabled if accept_ra
RE: [PATCH v1 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
Hi David Thanks a lot for Review, I have raised v2 after addressing your review comments from https://lkml.org/lkml/2021/1/14/1400. List of changes in v2: --- 1.) Replace accept_ra_defrtr_metric with ra_defrtr_metric. 2.) Change Type to __u32 instead of __s32. 3.) Change description in Documentation/networking/ip-sysctl.rst. 4.) Use proc_douintvec instead of proc_dointvec. 5.) Code style in ndisc_router_discovery(). 6.) Change Type to u32 instead of unsigned int. --- Thanks a lot again for help.
[PATCH v2 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu Changes in v1. --- 1.) Correct the call to rt6_add_dflt_router. --- Changes in v2. [Refer: lkml.org/lkml/2021/1/14/1400] --- 1.) Replace accept_ra_defrtr_metric to ra_defrtr_metric. 2.) Change Type to __u32 instead of __s32. 3.) Change description in Documentation/networking/ip-sysctl.rst. 4.) Use proc_douintvec instead of proc_dointvec. 5.) Code style in ndisc_router_discovery(). 6.) Change Type to u32 instead of unsigned int. --- Logs: For IPv4: Config in etc/network/interfaces ``` auto eth0 iface eth0 inet dhcp metric 4261413864 ``` IPv4 Kernel Route Table: ``` $ ip route list default via 172.21.47.1 dev eth0 metric 4261413864 ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over DHCPv4 default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m ``` ***i.e. User can prefer Default Router learned via Routing Protocol in IPv4.*** ***Similar behavior is not possible for IPv6, without this fix.*** After fix [for IPv6]: ``` sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.ra_defrtr_metric=1996489705 ``` IP monitor: [When IPv6 RA is received] ``` default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 pref high ``` Kernel IPv6 routing table ``` $ ip -6 route list default via fe80::be16:65ff:feb3:ce8e dev eth0 proto ra metric 1996489705 expires 21sec hoplimit 64 pref high ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over IPv6 RA default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::xx16::feb3:ce8e, eth0, 6d07h43m ``` If the metric is changed later, the effect will be seen only when next IPv6 RA is received, because the default route must be fully controlled by RA msg. Below metric is changed from 1996489705 to 1996489704. ``` $ sudo sysctl -w net.ipv6.conf.eth0.ra_defrtr_metric=1996489704 net.ipv6.conf.eth0.ra_defrtr_metric = 1996489704 ``` IP monitor: [On next IPv6 RA msg, Kernel deletes prev route and installs new route with updated metric] ``` Deleted default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 expires 3sec hoplimit 64 pref high default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489704 pref high ``` --- Documentation/networking/ip-sysctl.rst | 12 include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 14 ++ net/ipv6/route.c | 5 +++-- 8 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index dd2b12a32b73..c4b8d4b8d213 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1871,6 +1871,18 @@ accept_ra_defrtr - BOOLEAN - enabled if accept_ra is enabled. - disabled if accept_ra is disabled. +ra_defrtr_metr
RE: [PATCH v0 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
Thanks for the hint, Yeah I missed the call to rt6_add_dflt_router while applying patch to master branch. I am developer of SONiC OS (https://azure.github.io/SONiC/) in LinkedIn. We are planning to move to IPv6 only network and I realise that IPv6 needs capability to let administrator configure metric on default route learned via Router Advertisement in Linux. We support a fixed value 1024 today in Linux. Note for IPv4, administrator can configure metric on default route learned via DHCPv4. Kindly Review the fix, this feature is useful for IPv6 and Thanks Again.
[PATCH v1 net-next 0/1] Allow user to set metric on default route learned via Router Advertisement.
Allow user to set metric on default route learned via Router Advertisement. Note: RFC 4191 does not say anything for metric for IPv6 default route. Fix: For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config in etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Logs: For IPv4: Config in etc/network/interfaces ``` auto eth0 iface eth0 inet dhcp metric 4261413864 ``` IPv4 Kernel Route Table: ``` $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric RefUse Iface 0.0.0.0 172.11.44.1 0.0.0.0 UG-33553432 00 eth0 ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over DHCPv4 default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m ``` i.e. User can prefer Default Router learned via Routing Protocol, Similar behavior is not possible for IPv6, without this fix. After fix [for IPv6]: ``` sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.accept_ra_defrtr_metric=0x770003e9 ``` IP monitor: ``` default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 pref high ``` Kernel IPv6 routing table ``` DestinationNext Hop Flag Met Ref Use If ::/0 fe80::xx16::feb3:ce8e UGDAe 1996489705 0 0 eth0 ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over IPv6 RA default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::xx16::feb3:ce8e, eth0, 6d07h43m ``` If the metric is changed later, the effect will be seen only when IPv6 RA is received, because the default route must be fully controlled by RA msg. ``` admin@lnos-x1-a-asw03:~$ sudo sysctl -w net.ipv6.conf.eth0.accept_ra_defrtr_metric=0x770003e8 net.ipv6.conf.eth0.accept_ra_defrtr_metric = 0x770003e8 ``` IP monitor: when metric is changed after learning Default Route from previous IPv6 RA msg: ``` Deleted default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 expires 3sec hoplimit 64 pref high default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489704 pref high ``` Praveen Chaudhary (1): Allow user to set metric on default route learned via Router Advertisement. Documentation/networking/ip-sysctl.rst | 18 ++ include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 14 ++ net/ipv6/route.c | 5 +++-- 8 files changed, 46 insertions(+), 7 deletions(-) base-commit: 139711f033f636cc78b6aaf7363252241b9698ef -- 2.29.0
[PATCH v1 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu Changes in v1. --- 1.) Correct the call to rt6_add_dflt_router. --- --- Documentation/networking/ip-sysctl.rst | 18 ++ include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 14 ++ net/ipv6/route.c | 5 +++-- 8 files changed, 46 insertions(+), 7 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index dd2b12a32b73..384159081d91 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1871,6 +1871,24 @@ accept_ra_defrtr - BOOLEAN - enabled if accept_ra is enabled. - disabled if accept_ra is disabled. +accept_ra_defrtr_metric - INTEGER + Route metric for default route learned in Router Advertisement. This + value will be assigned as metric for the route learned via IPv6 Router + Advertisement. + + Possible values are: + 0: + Use default value i.e. IP6_RT_PRIO_USER 1024. + 0x to -1: + -ve values represent high route metric, value will be treated as + unsigned value. This behaviour is inline with current IPv4 metric + shown with commands such as "route -n" or "ip route list". + 1 to 0x7FF: + +ve values will be used as is for route metric. + + Functional default: enabled if accept_ra_defrtr is enabled. + disabled if accept_ra_defrtr is disabled. + accept_ra_from_local - BOOLEAN Accept RA with source-address that is found on local machine if the RA is otherwise proper and able to be accepted. diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index dda61d150a13..19af90c77200 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -31,6 +31,7 @@ struct ipv6_devconf { __s32 max_desync_factor; __s32 max_addresses; __s32 accept_ra_defrtr; + __s32 accept_ra_defrtr_metric; __s32 accept_ra_min_hop_limit; __s32 accept_ra_pinfo; __s32 ignore_routes_with_linkdown; diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 2a5277758379..a470bdab2420 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h @@ -174,7 +174,8 @@ struct fib6_info *rt6_get_dflt_router(struct net *net, struct net_device *dev); struct fib6_info *rt6_add_dflt_router(struct net *net, const struct in6_addr *gwaddr, -struct net_device *dev, unsigned int pref); +struct net_device *dev, unsigned int pref, +unsigned int defrtr_usr_metric); void rt6_purge_dflt_routers(struct net *net); diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h index 13e8751bf24a..945de5de5144 100644 --- a/include/uapi/linux/ipv6.h +++ b/include/uapi/linux/ipv6.h @@ -189,6 +189,7 @@ enum { DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN, DEVCONF_NDISC_TCLASS, DEVCONF_RPL_SEG_ENABLED, + DEVCONF_ACCEPT_RA_DEFRTR_METRIC, DEVCONF_MAX }; diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h index 458179df9b27..5e79c196e33c 100644 --- a/include/uapi/linux/sysctl.h +++ b/include/uapi/linux/sysctl.h @@ -571,6 +571,7 @@ enum { NET_IPV6_ACCEPT_SOURCE_ROUTE=25, NET_IPV6_ACCEPT_RA_FROM_LOCAL=26, NET_IPV6_ACCEPT_RA_RT_INFO_MIN_PLEN=27, + NET_IPV6_ACCEPT_RA_DEFRTR_METRIC=28, __NET_IPV6_MAX }; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index eff2cacd5209..702ec4a33936 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -205,6 +205,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, @@ -260,6 +261,7 @@ static struct ipv6_devconf ipv6_devcon
RE: [PATCH v0 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
Hi Jakub Thanks for the review, Sure, I will reraise the patch (again v0i, sonce no code changes) after adding space before '<'. This patch adds lines in 'include/uapi/', that requires ABI version changes for debian build. I am not sure, if we need any such changes to avoid breaking allmodconfig. It will be really helpful, if you can look at the patch once 'https://lkml.org/lkml/2021/1/11/1668' and suggest on this. Thanks a lot again.
[PATCH v0 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement.
For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu --- Documentation/networking/ip-sysctl.rst | 18 ++ include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 12 +--- net/ipv6/route.c | 5 +++-- 8 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index dd2b12a32b73..384159081d91 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1871,6 +1871,24 @@ accept_ra_defrtr - BOOLEAN - enabled if accept_ra is enabled. - disabled if accept_ra is disabled. +accept_ra_defrtr_metric - INTEGER + Route metric for default route learned in Router Advertisement. This + value will be assigned as metric for the route learned via IPv6 Router + Advertisement. + + Possible values are: + 0: + Use default value i.e. IP6_RT_PRIO_USER 1024. + 0x to -1: + -ve values represent high route metric, value will be treated as + unsigned value. This behaviour is inline with current IPv4 metric + shown with commands such as "route -n" or "ip route list". + 1 to 0x7FF: + +ve values will be used as is for route metric. + + Functional default: enabled if accept_ra_defrtr is enabled. + disabled if accept_ra_defrtr is disabled. + accept_ra_from_local - BOOLEAN Accept RA with source-address that is found on local machine if the RA is otherwise proper and able to be accepted. diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index dda61d150a13..19af90c77200 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -31,6 +31,7 @@ struct ipv6_devconf { __s32 max_desync_factor; __s32 max_addresses; __s32 accept_ra_defrtr; + __s32 accept_ra_defrtr_metric; __s32 accept_ra_min_hop_limit; __s32 accept_ra_pinfo; __s32 ignore_routes_with_linkdown; diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 2a5277758379..a470bdab2420 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h @@ -174,7 +174,8 @@ struct fib6_info *rt6_get_dflt_router(struct net *net, struct net_device *dev); struct fib6_info *rt6_add_dflt_router(struct net *net, const struct in6_addr *gwaddr, -struct net_device *dev, unsigned int pref); +struct net_device *dev, unsigned int pref, +unsigned int defrtr_usr_metric); void rt6_purge_dflt_routers(struct net *net); diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h index 13e8751bf24a..945de5de5144 100644 --- a/include/uapi/linux/ipv6.h +++ b/include/uapi/linux/ipv6.h @@ -189,6 +189,7 @@ enum { DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN, DEVCONF_NDISC_TCLASS, DEVCONF_RPL_SEG_ENABLED, + DEVCONF_ACCEPT_RA_DEFRTR_METRIC, DEVCONF_MAX }; diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h index 458179df9b27..5e79c196e33c 100644 --- a/include/uapi/linux/sysctl.h +++ b/include/uapi/linux/sysctl.h @@ -571,6 +571,7 @@ enum { NET_IPV6_ACCEPT_SOURCE_ROUTE=25, NET_IPV6_ACCEPT_RA_FROM_LOCAL=26, NET_IPV6_ACCEPT_RA_RT_INFO_MIN_PLEN=27, + NET_IPV6_ACCEPT_RA_DEFRTR_METRIC=28, __NET_IPV6_MAX }; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index eff2cacd5209..702ec4a33936 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -205,6 +205,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, @@ -260,6 +261,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { .max_desync_factor = MAX_DESYNC_FACTOR,
[PATCH v0 net-next 0/1] Allow user to set metric on default route learned via Router Advertisement.
Allow user to set metric on default route learned via Router Advertisement. Note: RFC 4191 does not say anything for metric for IPv6 default route. Fix: For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config in etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Logs: For IPv4: Config in etc/network/interfaces ``` auto eth0 iface eth0 inet dhcp metric 4261413864 ``` IPv4 Kernel Route Table: ``` $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric RefUse Iface 0.0.0.0 172.11.44.1 0.0.0.0 UG-33553432 00 eth0 ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over DHCPv4 default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m ``` i.e. User can prefer Default Router learned via Routing Protocol, Similar behavior is not possible for IPv6, without this fix. After fix [for IPv6]: ``` sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.accept_ra_defrtr_metric=0x770003e9 ``` IP monitor: ``` default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 pref high ``` Kernel IPv6 routing table ``` DestinationNext Hop Flag Met Ref Use If ::/0 fe80::xx16::feb3:ce8e UGDAe 1996489705 0 0 eth0 ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over IPv6 RA default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::xx16::feb3:ce8e, eth0, 6d07h43m ``` If the metric is changed later, the effect will be seen only when IPv6 RA is received, because the default route must be fully controlled by RA msg. ``` admin@lnos-x1-a-asw03:~$ sudo sysctl -w net.ipv6.conf.eth0.accept_ra_defrtr_metric=0x770003e8 net.ipv6.conf.eth0.accept_ra_defrtr_metric = 0x770003e8 ``` IP monitor: when metric is changed after learning Default Route from previous IPv6 RA msg: ``` Deleted default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 expires 3sec hoplimit 64 pref high default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489704 pref high ``` Praveen Chaudhary (1): Allow user to set metric on default route learned via Router Advertisement. Documentation/networking/ip-sysctl.rst | 18 ++ include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 12 +--- net/ipv6/route.c | 5 +++-- 8 files changed, 45 insertions(+), 6 deletions(-) base-commit: 139711f033f636cc78b6aaf7363252241b9698ef -- 2.29.0
[PATCH v0 net-next 1/1] Allow user to set metric on default route learned via Router Advertisement. Router Advertisement.
Fix: For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu --- Documentation/networking/ip-sysctl.rst | 8 include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 15 +++ net/ipv6/route.c | 8 +--- 8 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index dd2b12a32b73..073c1f3f8429 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1871,6 +1871,14 @@ accept_ra_defrtr - BOOLEAN - enabled if accept_ra is enabled. - disabled if accept_ra is disabled. +accept_ra_defrtr_metric - INTEGER + Metric for default router learned in Router Advertisement. + + Functional default: + + * 0 if accept_ra_defrtr is enabled. + * Ignored, if accept_ra_defrtr is enabled. + accept_ra_from_local - BOOLEAN Accept RA with source-address that is found on local machine if the RA is otherwise proper and able to be accepted. diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index dda61d150a13..19af90c77200 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -31,6 +31,7 @@ struct ipv6_devconf { __s32 max_desync_factor; __s32 max_addresses; __s32 accept_ra_defrtr; + __s32 accept_ra_defrtr_metric; __s32 accept_ra_min_hop_limit; __s32 accept_ra_pinfo; __s32 ignore_routes_with_linkdown; diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 2a5277758379..a470bdab2420 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h @@ -174,7 +174,8 @@ struct fib6_info *rt6_get_dflt_router(struct net *net, struct net_device *dev); struct fib6_info *rt6_add_dflt_router(struct net *net, const struct in6_addr *gwaddr, -struct net_device *dev, unsigned int pref); +struct net_device *dev, unsigned int pref, +unsigned int defrtr_usr_metric); void rt6_purge_dflt_routers(struct net *net); diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h index 13e8751bf24a..945de5de5144 100644 --- a/include/uapi/linux/ipv6.h +++ b/include/uapi/linux/ipv6.h @@ -189,6 +189,7 @@ enum { DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN, DEVCONF_NDISC_TCLASS, DEVCONF_RPL_SEG_ENABLED, + DEVCONF_ACCEPT_RA_DEFRTR_METRIC, DEVCONF_MAX }; diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h index 458179df9b27..5e79c196e33c 100644 --- a/include/uapi/linux/sysctl.h +++ b/include/uapi/linux/sysctl.h @@ -571,6 +571,7 @@ enum { NET_IPV6_ACCEPT_SOURCE_ROUTE=25, NET_IPV6_ACCEPT_RA_FROM_LOCAL=26, NET_IPV6_ACCEPT_RA_RT_INFO_MIN_PLEN=27, + NET_IPV6_ACCEPT_RA_DEFRTR_METRIC=28, __NET_IPV6_MAX }; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index eff2cacd5209..702ec4a33936 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -205,6 +205,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, @@ -260,6 +261,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, @@ -5475,6 +5477,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_
[PATCH v0 net-next 0/1] Allow user to set metric on default route learned via Router Advertisement.
Allow user to set metric on default route learned via Router Advertisement. Note: RFC 4191 does not say anything for metric for IPv6 default route. Fix: For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config in etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Logs: For IPv4: Config in etc/network/interfaces ``` auto eth0 iface eth0 inet dhcp metric 4261413864 ``` IPv4 Kernel Route Table: ``` $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric RefUse Iface 0.0.0.0 172.11.44.1 0.0.0.0 UG-33553432 00 eth0 ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over DHCPv4 default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m ``` i.e. User can prefer Default Router learned via Routing Protocol, Similar behavior is not possible for IPv6, without this fix. After fix [for IPv6]: ``` sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.accept_ra_defrtr_metric=0x770003e9 ``` IP monitor: ``` default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 pref high ``` Kernel IPv6 routing table ``` DestinationNext Hop Flag Met Ref Use If ::/0 fe80::xx16::feb3:ce8e UGDAe 1996489705 0 0 eth0 ``` FRR Table, if a static route is configured. [In real scenario, it is useful to prefer BGP learned default route over IPv6 RA default route.] ``` Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::xx16::feb3:ce8e, eth0, 6d07h43m ``` If the metric is changed later, the effect will be seen only when IPv6 RA is received, because the default route must be fully controlled by RA msg. ``` admin@lnos-x1-a-asw03:~$ sudo sysctl -w net.ipv6.conf.eth0.accept_ra_defrtr_metric=0x770003e8 net.ipv6.conf.eth0.accept_ra_defrtr_metric = 0x770003e8 ``` IP monitor: when metric is changed after learning Default Route from previous IPv6 RA msg: ``` Deleted default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489705 expires 3sec hoplimit 64 pref high default via fe80::xx16::feb3:ce8e dev eth0 proto ra metric 1996489704 pref high ``` Praveen Chaudhary (1): Allow user to set metric on default route learned via Router Advertisement. Documentation/networking/ip-sysctl.rst | 8 include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 15 +++ net/ipv6/route.c | 8 +--- 8 files changed, 39 insertions(+), 8 deletions(-) base-commit: 139711f033f636cc78b6aaf7363252241b9698ef -- 2.29.0
[PATCH] Allow user to set metric on default route learned via Router Advertisement.
Fix: For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu --- Documentation/networking/ip-sysctl.rst | 8 include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 15 +++ net/ipv6/route.c | 8 +--- 8 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst index dd2b12a..073c1f3 100644 --- a/Documentation/networking/ip-sysctl.rst +++ b/Documentation/networking/ip-sysctl.rst @@ -1871,6 +1871,14 @@ accept_ra_defrtr - BOOLEAN - enabled if accept_ra is enabled. - disabled if accept_ra is disabled. +accept_ra_defrtr_metric - INTEGER + Metric for default router learned in Router Advertisement. + + Functional default: + + * 0 if accept_ra_defrtr is enabled. + * Ignored, if accept_ra_defrtr is enabled. + accept_ra_from_local - BOOLEAN Accept RA with source-address that is found on local machine if the RA is otherwise proper and able to be accepted. diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index dda61d1..19af90c 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -31,6 +31,7 @@ struct ipv6_devconf { __s32 max_desync_factor; __s32 max_addresses; __s32 accept_ra_defrtr; + __s32 accept_ra_defrtr_metric; __s32 accept_ra_min_hop_limit; __s32 accept_ra_pinfo; __s32 ignore_routes_with_linkdown; diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 2a52777..a470bda 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h @@ -174,7 +174,8 @@ struct fib6_info *rt6_get_dflt_router(struct net *net, struct net_device *dev); struct fib6_info *rt6_add_dflt_router(struct net *net, const struct in6_addr *gwaddr, -struct net_device *dev, unsigned int pref); +struct net_device *dev, unsigned int pref, +unsigned int defrtr_usr_metric); void rt6_purge_dflt_routers(struct net *net); diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h index 13e8751..945de5d 100644 --- a/include/uapi/linux/ipv6.h +++ b/include/uapi/linux/ipv6.h @@ -189,6 +189,7 @@ enum { DEVCONF_ACCEPT_RA_RT_INFO_MIN_PLEN, DEVCONF_NDISC_TCLASS, DEVCONF_RPL_SEG_ENABLED, + DEVCONF_ACCEPT_RA_DEFRTR_METRIC, DEVCONF_MAX }; diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h index 458179d..5e79c19 100644 --- a/include/uapi/linux/sysctl.h +++ b/include/uapi/linux/sysctl.h @@ -571,6 +571,7 @@ enum { NET_IPV6_ACCEPT_SOURCE_ROUTE=25, NET_IPV6_ACCEPT_RA_FROM_LOCAL=26, NET_IPV6_ACCEPT_RA_RT_INFO_MIN_PLEN=27, + NET_IPV6_ACCEPT_RA_DEFRTR_METRIC=28, __NET_IPV6_MAX }; diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index eff2cac..702ec4a 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -205,6 +205,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, @@ -260,6 +261,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, @@ -5475,6 +5477,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_
[PATCH] Allow user to set metric on default route learned via Router Advertisement.
Allow user to set metric on default route learned via Router Advertisement. Not: RFC 4191 does not say anything for metric for IPv6 default route. Fix: For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Logs: For IPv4: Config in etc/network/interfaces ``` auto eth0 iface eth0 inet dhcp metric 4261413864 ``` IPv4 Kernel Route Table: ``` $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric RefUse Iface 0.0.0.0 172.11.44.1 0.0.0.0 UG-33553432 00 eth0 ``` FRR Table, if default route is learned via routing protocol too. ``` # show ip route Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m ``` i.e. User can prefer Default Router learned via Routing Protocol, Similar behavior is not possible for IPv6, without this fix. After fix [for IPv6]: ``` sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.accept_ra_defrtr_metric=0x770003e9 ``` IP monitor: ``` default via fe80::be16:65ff:feb3:ce8e dev eth0 proto ra metric 1996489705 pref high ``` Kernel IPv6 routing table ``` DestinationNext Hop Flag Met Ref Use If ::/0 fe80::be16:65ff:feb3:ce8e UGDAe 1996489705 0 0 eth0 ``` FRR Routing Table, if default route is learned via routing protocol. # show ipv6 route Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::be16:65ff:feb3:ce8e, eth0, 6d07h43m -------- Praveen Chaudhary (1): Allow user to set metric on default route learned via Router Advertisement. Documentation/networking/ip-sysctl.rst | 8 include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 15 +++ net/ipv6/route.c | 8 +--- 8 files changed, 39 insertions(+), 8 deletions(-) -- 2.7.4
[PATCH] Allow user to set metric on default route learned via Router Advertisement.
Allow user to set metric on default route learned via Router Advertisement. Not: RFC 4191 does not say anything for metric for IPv6 default route. Fix: For IPv4, default route is learned via DHCPv4 and user is allowed to change metric using config etc/network/interfaces. But for IPv6, default route can be learned via RA, for which, currently a fixed metric value 1024 is used. Ideally, user should be able to configure metric on default route for IPv6 similar to IPv4. This fix adds sysctl for the same. Logs: For IPv4: Config in etc/network/interfaces ``` auto eth0 iface eth0 inet dhcp metric 4261413864 ``` IPv4 Kernel Route Table: ``` $ sudo route -n Kernel IP routing table Destination Gateway Genmask Flags Metric RefUse Iface 0.0.0.0 172.11.44.1 0.0.0.0 UG-33553432 00 eth0 ``` FRR Table, if default route is learned via routing protocol too. ``` # show ip route Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - IS-IS, B - BGP, P - PIM, E - EIGRP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* 0.0.0.0/0 [20/0] is directly connected, eth0, 00:00:03 K 0.0.0.0/0 [254/1000] via 172.21.47.1, eth0, 6d08h51m ``` i.e. User can prefer Default Router learned via Routing Protocol, Similar behavior is not possible for IPv6, without this fix. After fix [for IPv6]: ``` sudo sysctl -w net.ipv6.conf.eth0.net.ipv6.conf.eth0.accept_ra_defrtr_metric=0x770003e9 ``` IP monitor: ``` default via fe80::be16:65ff:feb3:ce8e dev eth0 proto ra metric 1996489705 pref high ``` Kernel IPv6 routing table ``` DestinationNext Hop Flag Met Ref Use If ::/0 fe80::be16:65ff:feb3:ce8e UGDAe 1996489705 0 0 eth0 ``` FRR Routing Table, if default route is learned via routing protocol. # show ipv6 route Codes: K - kernel route, C - connected, S - static, R - RIPng, O - OSPFv3, I - IS-IS, B - BGP, N - NHRP, T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP, > - selected route, * - FIB route S>* ::/0 [20/0] is directly connected, eth0, 00:00:06 K ::/0 [119/1001] via fe80::be16:65ff:feb3:ce8e, eth0, 6d07h43m -------- Praveen Chaudhary (1): Allow user to set metric on default route learned via Router Advertisement. Documentation/networking/ip-sysctl.rst | 8 include/linux/ipv6.h | 1 + include/net/ip6_route.h| 3 ++- include/uapi/linux/ipv6.h | 1 + include/uapi/linux/sysctl.h| 1 + net/ipv6/addrconf.c| 10 ++ net/ipv6/ndisc.c | 15 +++ net/ipv6/route.c | 8 +--- 8 files changed, 39 insertions(+), 8 deletions(-) -- 2.7.4
[PATCH] Fix skb->csum calculation when netfilter manipulation for NF_NAT_MANIP_SRC\DST is done on IPV6 packet.
T --to-source 2a04::62:4::2 -A POSTROUTING -p tcp -m tcp --dport 53 -o Ethernet+ -j SNAT --to-source 2a04::62:4::2 ``` 2.) ``` pchaudha@asw03:~$ sudo /etc/network/if-pre-up.d/iptables ``` 3.) UDPv6 DNS query: ``` pchaudha@asw03:~$ host facebook.com 2a04::xx:1::c216 Using domain server: Name: 2a04::32:1::c216 Address: 2a04::32:1::c216#53 Aliases: facebook.com has address 157.240.11.35 facebook.com has IPv6 address 2a03:2880:f10d:183:face:b00c:0:25de facebook.com mail is handled by 10 smtpin.vvv.facebook.com. ``` 4.) JPROBE LOGS: ``` Oct 22 05:51:20.748153 asw03 NOTICE kernel: [611954.922595] nf_nat_ipv6_manip_pkt: skb:9faa7c9bf400 t->dst.protonum=17 Oct 22 05:51:20.748186 asw03 NOTICE kernel: [611954.922600] inet_proto_csum_replace16: skb:9faa7c9bf400 ips=2 csumv=1 csumsw=1 csum=4914e05c Oct 22 05:51:20.748192 asw03 NOTICE kernel: [611954.922601] inet_proto_csum_replace16: new sum:c734e05c <<<<<<<< Oct 22 05:51:20.748195 asw03 NOTICE kernel: [611954.922605] ip6_rcv_finish: skb:9faa7c9bf400 ips=2 csumv=1 csumsw=1 csum=4914e05c ``` 5.) TCPv6 query: ``` pchaudha@asw03:~$ host -T facebook.com 2a04::32:1::c216 Using domain server: Name: 2a04::32:1::c216 Address: 2a04::32:1::c216#53 Aliases: facebook.com has address 31.13.70.36 facebook.com has IPv6 address 2a03:2880:f10d:183:face:b00c:0:25de facebook.com mail is handled by 10 smtpin.vvv.facebook.com. -- ``` 6.) JPROBE LOGS: ``` Oct 22 18:13:29.199793 asw03 NOTICE kernel: [656483.605018] nf_nat_ipv6_manip_pkt: skb:9faab3e79400 t->dst.protonum=6 Oct 22 18:13:29.199826 asw03 NOTICE kernel: [656483.605032] inet_proto_csum_replace16: skb:9faab3e79400 ips=2 csumv=1 csumsw=1 csum=c6796dec Oct 22 18:13:29.199831 asw03 NOTICE kernel: [656483.605033] inet_proto_csum_replace16: new sum:c4996dec Oct 22 18:13:29.199835 asw03 NOTICE kernel: [656483.605038] ip6_rcv_finish: skb:9faab3e79400 ips=2 csumv=1 csumsw=1 csum=c6796dec ``` Praveen Chaudhary (1): [netfilter]: Fix skb->csum calculation when netfilter manipulation for NF_NAT_MANIP_SRC\DST is done on IPV6 packet. include/net/checksum.h | 2 ++ net/core/utils.c | 13 + net/netfilter/nf_nat_proto.c | 2 ++ 3 files changed, 17 insertions(+) -- 2.7.4
[PATCH] [netfilter]: Fix skb->csum calculation when netfilter manipulation for NF_NAT_MANIP_SRC\DST is done on IPV6 packet.
Update skb->csum, when netfilter code updates IPV6 SRC\DST address in IPV6 HEADER due to iptable rule. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu Signed-off-by: Andy Stracner --- include/net/checksum.h | 2 ++ net/core/utils.c | 13 + net/netfilter/nf_nat_proto.c | 2 ++ 3 files changed, 17 insertions(+) diff --git a/include/net/checksum.h b/include/net/checksum.h index 97bf488..d7d28b7 100644 --- a/include/net/checksum.h +++ b/include/net/checksum.h @@ -145,6 +145,8 @@ void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, const __be32 *from, const __be32 *to, bool pseudohdr); +void inet_proto_skb_csum_replace16(struct sk_buff *skb, + const __be32 *from, const __be32 *to); void inet_proto_csum_replace_by_diff(__sum16 *sum, struct sk_buff *skb, __wsum diff, bool pseudohdr); diff --git a/net/core/utils.c b/net/core/utils.c index 6b6e51d..ab3284b 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -458,6 +458,19 @@ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, } EXPORT_SYMBOL(inet_proto_csum_replace16); +void inet_proto_skb_csum_replace16(struct sk_buff *skb, + const __be32 *from, const __be32 *to) +{ + __be32 diff[] = { + ~from[0], ~from[1], ~from[2], ~from[3], + to[0], to[1], to[2], to[3], + }; + if (skb->ip_summed == CHECKSUM_COMPLETE) + skb->csum = csum_partial(diff, sizeof(diff), + skb->csum); +} +EXPORT_SYMBOL(inet_proto_skb_csum_replace16); + void inet_proto_csum_replace_by_diff(__sum16 *sum, struct sk_buff *skb, __wsum diff, bool pseudohdr) { diff --git a/net/netfilter/nf_nat_proto.c b/net/netfilter/nf_nat_proto.c index 0a59c14..de94590 100644 --- a/net/netfilter/nf_nat_proto.c +++ b/net/netfilter/nf_nat_proto.c @@ -467,6 +467,8 @@ static void nf_nat_ipv6_csum_update(struct sk_buff *skb, } inet_proto_csum_replace16(check, skb, oldip->s6_addr32, newip->s6_addr32, true); + inet_proto_skb_csum_replace16(skb, oldip->s6_addr32, + newip->s6_addr32); #endif } -- 2.7.4