<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,<br><br>>Can you be elaborate more in detail what use case you want to cover</div><div>>with this patch; in other words what is not working now ?</div><div>Ok,</div><div>my setup:</div><div><span style="white-space:pre"> </span>Two peer routers A and B which both connected to gateway C.</div><div><span style="white-space:pre"> </span> Routers A and B have public IPv6 addresses on WAN interfaces from same subnet (because of RA on C) and private IPv6 addresses on LAN interfaces.</div><div>and issue:</div><div><span style="white-space:pre"> </span>If I unplug router B from C and then plug it in LAN port of router A:</div><div><span style="white-space:pre"> </span>1) Router B does not send Router Solicitation message. So router B does not have a valid gateway for some time.</div><div><span style="white-space:pre"> </span>2) Router B does not delete old IPv6 address on the WAN. After first Router Advertisement message router B is capable to send a request via new gateway A, but it can't receive responses because of invalid/old source address in request.</div><div><br><br></div><div>>Why do you want to restart RA if an SIGUSR2 signal is received ?</div><div>Because I assume that SIGUSR2 signal is equivalent to link-up event (see odhcp6c:674 -> <a href="https://git.openwrt.org/?p=project/odhcp6c.git;a=blob;f=src/odhcp6c.c;h=19a86f2654bf3c59b0f47cf0aedd87235187bf89;hb=d2e247d8d87ecf8c60fcf0acdad05667bd379521#l674">https://git.openwrt.org/?p=project/odhcp6c.git;a=blob;f=src/odhcp6c.c;h=19a86f2654bf3c59b0f47cf0aedd87235187bf89;hb=d2e247d8d87ecf8c60fcf0acdad05667bd379521#l674</a>).</div><div>In my case I use hotplug script witch on link-up sends SIGUSR2 signal to odhcp6c (it's connected to bridge interface).</div><div>ra_restart () could be called without condition in beginning of the main loop.<br><br>Br,<br>Pavel</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 18 Mar 2019 at 18:26, Hans Dedecker <<a href="mailto:dedeckeh@gmail.com">dedeckeh@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
On Mon, Mar 18, 2019 at 2:43 PM <<a href="mailto:pavel.merzlyakov@gmail.com" target="_blank">pavel.merzlyakov@gmail.com</a>> wrote:<br>
><br>
> From: Pavel Merzlyakov <<a href="mailto:pavel.merzlyakov@gmail.com" target="_blank">pavel.merzlyakov@gmail.com</a>><br>
><br>
> A subnet may be changed after link-up event<br>
Can you be elaborate more in detail what use case you want to cover<br>
with this patch; in other words what is not working now ?<br>
><br>
> Signed-off-by: Pavel Merzlyakov <<a href="mailto:pavel.merzlyakov@gmail.com" target="_blank">pavel.merzlyakov@gmail.com</a>><br>
> ---<br>
> src/odhcp6c.c | 3 +++<br>
> src/ra.c | 20 +++++++++++++++++---<br>
> src/ra.h | 1 +<br>
> 3 files changed, 21 insertions(+), 3 deletions(-)<br>
><br>
> diff --git a/src/odhcp6c.c b/src/odhcp6c.c<br>
> index 19a86f2..dd20f39 100644<br>
> --- a/src/odhcp6c.c<br>
> +++ b/src/odhcp6c.c<br>
> @@ -455,6 +455,9 @@ int main(_unused int argc, char* const argv[])<br>
><br>
> syslog(LOG_NOTICE, "(re)starting transaction on %s", ifname);<br>
><br>
> + if (signal_usr2)<br>
> + ra_restart();<br>
Why do you want to restart RA if an SIGUSR2 signal is received ?<br>
<br>
Hans<br>
> +<br>
> signal_usr1 = signal_usr2 = false;<br>
> int mode = dhcpv6_set_ia_mode(ia_na_mode, ia_pd_mode);<br>
> if (mode != DHCPV6_STATELESS)<br>
> diff --git a/src/ra.c b/src/ra.c<br>
> index 898f449..917df11 100644<br>
> --- a/src/ra.c<br>
> +++ b/src/ra.c<br>
> @@ -55,6 +55,7 @@ static int sock = -1, rtnl = -1;<br>
> static int if_index = 0;<br>
> static char if_name[IF_NAMESIZE] = {0};<br>
> static volatile int rs_attempt = 0;<br>
> +static const int rs_attempt_limit = 4;<br>
> static struct in6_addr lladdr = IN6ADDR_ANY_INIT;<br>
> static unsigned int ra_options = 0;<br>
> static unsigned int ra_holdoff_interval = 0;<br>
> @@ -179,6 +180,20 @@ failure:<br>
> return -1;<br>
> }<br>
><br>
> +void ra_restart(void)<br>
> +{<br>
> + const int rs_attempt_old = rs_attempt;<br>
> +<br>
> + odhcp6c_clear_state(STATE_RA_PREFIX);<br>
> + odhcp6c_clear_state(STATE_RA_ROUTE);<br>
> + odhcp6c_clear_state(STATE_RA_DNS);<br>
> + odhcp6c_clear_state(STATE_RA_SEARCH);<br>
> +<br>
> + rs_attempt = 0;<br>
> + if (rs_attempt_old == 0 || rs_attempt_old >= rs_attempt_limit)<br>
> + ra_send_rs(SIGALRM);<br>
> +}<br>
> +<br>
> static void ra_send_rs(int signal __attribute__((unused)))<br>
> {<br>
> const struct sockaddr_in6 dest = {AF_INET6, 0, 0, ALL_IPV6_ROUTERS, if_index};<br>
> @@ -193,7 +208,7 @@ static void ra_send_rs(int signal __attribute__((unused)))<br>
> if (sendto(sock, &rs, len, MSG_DONTWAIT, (struct sockaddr*)&dest, sizeof(dest)) < 0)<br>
> syslog(LOG_ERR, "Failed to send RS (%s)", strerror(errno));<br>
><br>
> - if (++rs_attempt <= 3)<br>
> + if (++rs_attempt < rs_attempt_limit)<br>
> alarm(4);<br>
> }<br>
><br>
> @@ -243,8 +258,7 @@ bool ra_link_up(void)<br>
> if (ret) {<br>
> syslog(LOG_NOTICE, "carrier => %i event on %s", (int)!nocarrier, if_name);<br>
><br>
> - rs_attempt = 0;<br>
> - ra_send_rs(SIGALRM);<br>
> + ra_restart();<br>
> }<br>
><br>
> return ret;<br>
> diff --git a/src/ra.h b/src/ra.h<br>
> index 9acc8cd..4ec208f 100644<br>
> --- a/src/ra.h<br>
> +++ b/src/ra.h<br>
> @@ -46,5 +46,6 @@ struct icmpv6_opt_route_info {<br>
><br>
> int ra_init(const char *ifname, const struct in6_addr *ifid,<br>
> unsigned int options, unsigned int holdoff_interval);<br>
> +void ra_restart(void);<br>
> bool ra_link_up(void);<br>
> bool ra_process(void);<br>
> --<br>
> 2.21.0<br>
><br>
><br>
> _______________________________________________<br>
> openwrt-devel mailing list<br>
> <a href="mailto:openwrt-devel@lists.openwrt.org" target="_blank">openwrt-devel@lists.openwrt.org</a><br>
> <a href="https://lists.openwrt.org/mailman/listinfo/openwrt-devel" rel="noreferrer" target="_blank">https://lists.openwrt.org/mailman/listinfo/openwrt-devel</a><br>
</blockquote></div></div>