Re: unwind(8): forget learned forwarders when interface disappears

2020-09-12 Thread Florian Obser
On Sat, Sep 12, 2020 at 08:13:43PM +0300, Peter Pentchev wrote:
> On Sat, Sep 12, 2020 at 06:58:30PM +0200, Florian Obser wrote:
> > On Sat, Sep 12, 2020 at 05:15:08PM +0200, Klemens Nanni wrote:
> > > On Sat, Sep 12, 2020 at 05:11:00PM +0200, Klemens Nanni wrote:
> > > > Bit hard to read, what about aligning like this?
> > > > 
> > > > +   if ((rdns_proposal->src == 0 ||
> > > > +rdns_proposal->src == tmp->src) &&
> > > > +   (rdns_proposal->if_index == 0 ||
> > > > +   rdns_proposal->if_index == tmp->if_index))
> > > With a space here   ^
> > > 
> > 
> > I'd rather not, style(9):
> > Indentation is an 8 character tab.  Second level indents are four 
> > spaces.
> > 
> > Also, my editor would fix it up the next time I touch those lines.
> 
> Er... so what's the difference with the second line, two lines above
> that? "rdns_proposal->src == tmp->src" seems to have that space.

sure, because kn added it, have a look at the original diff, it's
formated completely different.

> 
> G'luck,
> Peter
> 
> -- 
> Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
> PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
> Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13



-- 
I'm not entirely sure you are real.



Re: unwind(8): forget learned forwarders when interface disappears

2020-09-12 Thread Peter Pentchev
On Sat, Sep 12, 2020 at 06:58:30PM +0200, Florian Obser wrote:
> On Sat, Sep 12, 2020 at 05:15:08PM +0200, Klemens Nanni wrote:
> > On Sat, Sep 12, 2020 at 05:11:00PM +0200, Klemens Nanni wrote:
> > > Bit hard to read, what about aligning like this?
> > > 
> > > + if ((rdns_proposal->src == 0 ||
> > > +  rdns_proposal->src == tmp->src) &&
> > > + (rdns_proposal->if_index == 0 ||
> > > + rdns_proposal->if_index == tmp->if_index))
> > With a space here   ^
> > 
> 
> I'd rather not, style(9):
>   Indentation is an 8 character tab.  Second level indents are four 
> spaces.
> 
> Also, my editor would fix it up the next time I touch those lines.

Er... so what's the difference with the second line, two lines above
that? "rdns_proposal->src == tmp->src" seems to have that space.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: unwind(8): forget learned forwarders when interface disappears

2020-09-12 Thread Florian Obser
On Sat, Sep 12, 2020 at 05:15:08PM +0200, Klemens Nanni wrote:
> On Sat, Sep 12, 2020 at 05:11:00PM +0200, Klemens Nanni wrote:
> > Bit hard to read, what about aligning like this?
> > 
> > +   if ((rdns_proposal->src == 0 ||
> > +rdns_proposal->src == tmp->src) &&
> > +   (rdns_proposal->if_index == 0 ||
> > +   rdns_proposal->if_index == tmp->if_index))
> With a space here   ^
> 

I'd rather not, style(9):
Indentation is an 8 character tab.  Second level indents are four 
spaces.

Also, my editor would fix it up the next time I touch those lines.

-- 
I'm not entirely sure you are real.



Re: unwind(8): forget learned forwarders when interface disappears

2020-09-12 Thread Klemens Nanni
On Sat, Sep 12, 2020 at 05:11:00PM +0200, Klemens Nanni wrote:
> Bit hard to read, what about aligning like this?
> 
> + if ((rdns_proposal->src == 0 ||
> +  rdns_proposal->src == tmp->src) &&
> + (rdns_proposal->if_index == 0 ||
> + rdns_proposal->if_index == tmp->if_index))
With a space here   ^



Re: unwind(8): forget learned forwarders when interface disappears

2020-09-12 Thread Klemens Nanni
On Sat, Sep 12, 2020 at 04:36:28PM +0200, Florian Obser wrote:
> ... say if you pull a usb stick.
...or if you play with^W^Wrecreate your trunk0 { em0 athn0 } uplink
without checking unwind.

Without this diff, unwind cannot recover;  with it, stuff just works for
me across destroy/create.

OK kn

> diff --git resolver.c resolver.c
> index 874ad5e76b3..8cf72db7250 100644
> --- resolver.c
> +++ resolver.c
> @@ -1952,10 +1952,13 @@ replace_autoconf_forwarders(struct imsg_rdns_proposal 
> *rdns_proposal)
>   }
>  
>   TAILQ_FOREACH(tmp, _forwarder_list, entry) {
> - /* if_index of zero signals to clear all proposals */
> - if (rdns_proposal->src == tmp->src &&
> - (rdns_proposal->if_index == 0 || rdns_proposal->if_index ==
> - tmp->if_index))
> + /*
> +  * if_index of zero signals to clear all proposals
> +  * src of zero signals interface gone
> +  */
> + if ((rdns_proposal->src == 0 || rdns_proposal->src ==
> + tmp->src) && (rdns_proposal->if_index == 0 ||
> + rdns_proposal->if_index == tmp->if_index))
Bit hard to read, what about aligning like this?

+   if ((rdns_proposal->src == 0 ||
+rdns_proposal->src == tmp->src) &&
+   (rdns_proposal->if_index == 0 ||
+   rdns_proposal->if_index == tmp->if_index))

>   continue;
>   if ((uw_forwarder = calloc(1, sizeof(struct uw_forwarder))) ==
>   NULL)



unwind(8): forget learned forwarders when interface disappears

2020-09-12 Thread Florian Obser
... say if you pull a usb stick.

OK?

diff --git frontend.c frontend.c
index 87141f81e8c..b92cde8226c 100644
--- frontend.c
+++ frontend.c
@@ -913,8 +913,21 @@ handle_route_message(struct rt_msghdr *rtm, struct 
sockaddr **rti_info)
 {
struct imsg_rdns_proposalrdns_proposal;
struct sockaddr_rtdns   *rtdns;
+   struct if_announcemsghdr*ifan;
 
switch (rtm->rtm_type) {
+   case RTM_IFANNOUNCE:
+   ifan = (struct if_announcemsghdr *)rtm;
+   if (ifan->ifan_what == IFAN_ARRIVAL)
+   break;
+   rdns_proposal.if_index = ifan->ifan_index;
+   rdns_proposal.src = 0;
+   rdns_proposal.rtdns.sr_family = AF_INET;
+   rdns_proposal.rtdns.sr_len = offsetof(struct sockaddr_rtdns,
+   sr_dns);
+   frontend_imsg_compose_resolver(IMSG_REPLACE_DNS, 0,
+   _proposal, sizeof(rdns_proposal));
+   break;
case RTM_IFINFO:
frontend_imsg_compose_resolver(IMSG_NETWORK_CHANGED, 0, NULL,
0);
diff --git resolver.c resolver.c
index 874ad5e76b3..8cf72db7250 100644
--- resolver.c
+++ resolver.c
@@ -1952,10 +1952,13 @@ replace_autoconf_forwarders(struct imsg_rdns_proposal 
*rdns_proposal)
}
 
TAILQ_FOREACH(tmp, _forwarder_list, entry) {
-   /* if_index of zero signals to clear all proposals */
-   if (rdns_proposal->src == tmp->src &&
-   (rdns_proposal->if_index == 0 || rdns_proposal->if_index ==
-   tmp->if_index))
+   /*
+* if_index of zero signals to clear all proposals
+* src of zero signals interface gone
+*/
+   if ((rdns_proposal->src == 0 || rdns_proposal->src ==
+   tmp->src) && (rdns_proposal->if_index == 0 ||
+   rdns_proposal->if_index == tmp->if_index))
continue;
if ((uw_forwarder = calloc(1, sizeof(struct uw_forwarder))) ==
NULL)
diff --git unwind.c unwind.c
index b17bf7e413c..d7ae76d4274 100644
--- unwind.c
+++ unwind.c
@@ -266,7 +266,8 @@ main(int argc, char *argv[])
AF_INET)) == -1)
fatal("route socket");
 
-   rtfilter = ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_PROPOSAL);
+   rtfilter = ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_PROPOSAL)
+   | ROUTE_FILTER(RTM_IFANNOUNCE);
if (setsockopt(frontend_routesock, AF_ROUTE, ROUTE_MSGFILTER,
, sizeof(rtfilter)) == -1)
fatal("setsockopt(ROUTE_MSGFILTER)");


-- 
I'm not entirely sure you are real.