Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-16 Thread Kristof Provost

> On 16 Dec 2015, at 13:09, Steven Hartland  wrote:
> 
> I've attached a patch which should fix if you could test that would be great, 
> but I'd still like to understand if there is something wrong elsewhere before 
> I do.

The board boots & works with this patch.

Thanks,
Kristof
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-16 Thread Adrian Chadd
hi,

yeah, switchports at the moment are pure L2 interfaces, they don't
have addressing. This may eventually change if etherswitch grows slave
switch port support.

But I didn't think it was creating ifnet interfaces, only miibusses
and mii's for link status.


-a


On 16 December 2015 at 04:09, Steven Hartland  wrote:
> On 15/12/2015 22:58, Kristof Provost wrote:
>>>
>>> On 15 Dec 2015, at 23:15, Kristof Provost  wrote:
>>> Based on the arp_announce() in the backtrace this commit looks like a
>>> possible cause.
>>
>> I see this in arp_announce():
>> KP: arp_announce() ifp->if_addr = 0
>>
>> So that explains why we panic in 'lladdr = IF_LLADDR(ifp);’.
>>
>> I’ve done a very quick hack:
>> diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
>> index 2214542..9b25356 100644
>> --- a/sys/netinet/if_ether.c
>> +++ b/sys/netinet/if_ether.c
>> @@ -1246,9 +1246,15 @@ arp_announce(struct ifnet *ifp)
>>  }
>>  IF_ADDR_RUNLOCK(ifp);
>>
>> -   lladdr = IF_LLADDR(ifp);
>> -   for (i = 0; i < cnt; i++) {
>> -   arp_announce_addr(ifp, head + i, lladdr);
>> +   printf("KP: %s() ifp = %p\n", __FUNCTION__, ifp);
>> +   printf("KP: %s() ifp->if_addr = %p\n", __FUNCTION__,
>> ifp->if_addr);
>> +
>> +   if (ifp->if_addr) {
>> +   printf("KP: %s() ifp->if_addr->ifa_addr = %p\n",
>> __FUNCTION__, ifp->if_addr->ifa_addr);
>> +   lladdr = IF_LLADDR(ifp);
>> +   for (i = 0; i < cnt; i++) {
>> +   arp_announce_addr(ifp, head + i, lladdr);
>> +   }
>>  }
>>  free(head, M_TEMP);
>>   }
>>
>> With this patch the device boots. I haven’t been able to verify if
>> everything works because of a different issue ("Shared object
>> "lib80211.so.1" not found, required by “ifconfig””, no doubt just a small
>> problem with the freebsd-wifi-build scripts).
>>
>> Regards,
>> Kristof
>
> Thanks for all the info Kristof appreciated.
>
> It seems really odd that you're getting a link up event for an interface
> that doesn't have a LLA, so I'm wondering if this is the result of an issue
> elsewhere which this change brings to light, its as though if_attach hasn't
> been called.
>
> Looking at your trace the device seems to be an arswitch. If it never
> allocates a LLA to each port then maybe the more correct fix would be to
> ensure it IFF_NOARP in if_flags?
>
> I've attached a patch which should fix if you could test that would be
> great, but I'd still like to understand if there is something wrong
> elsewhere before I do.
>
> Regards
> Steve
>
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-16 Thread Adrian Chadd
right, it's:

arswitch.c: err = mii_attach(sc->sc_dev, >miibus[phy],
sc->ifp[phy],
arswitch.c: device_get_nameunit(sc->miibus[phy]),



-a
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-16 Thread Alexander V . Chernikov
15.12.2015, 19:02, "Steven Hartland" :
> Author: smh
> Date: Tue Dec 15 16:02:11 2015
> New Revision: 292275
> URL: https://svnweb.freebsd.org/changeset/base/292275
>
> Log:
>   Fix lagg failover due to missing notifications
>
>   When using lagg failover mode neither Gratuitous ARP (IPv4) or Unsolicited
>   Neighbour Advertisements (IPv6) are sent to notify other nodes that the
>   address may have moved.
>
>   This results is slow failover, dropped packets and network outages for the
>   lagg interface when the primary link goes down.
>
>   We now use the new if_link_state_change_cond with the force param set to
>   allow lagg to force through link state changes and hence fire a
>   ifnet_link_event which are now monitored by rip and nd6.
>
>   Upon receiving these events each protocol trigger the relevant
>   notifications:
>   * inet4 => Gratuitous ARP
>   * inet6 => Unsolicited Neighbour Announce

Steven, I believe that having DELAY() called inside callout routine is 
incorrect - you are delaying other consumers for arbitrary amount of time.
If you really want to do it that way you should create separate taskqueue for 
that.
Also, destroying interface while doing these DELAYs would very likely crash the 
system
:"#define IN6_MAX_ANYCAST_DELAY_TIME_MS 100" is misguiding
There are some style(9) issues like lack of empty line between nd6_init() and 
nd6_ifnet_link_event()
...

>
>   This also fixes the carp IPv6 NA's that stopped working after r251584 which
>   added the ipv6_route__llma route.
>
>   The new behavour can be controlled using the sysctls:
>   * net.link.ether.inet.arp_on_link
>   * net.inet6.icmp6.nd6_on_link
>
>   Also removed unused param from lagg_port_state and added descriptions for 
> the
>   sysctls while here.
>
>   PR: 156226
>   MFC after: 1 month
>   Sponsored by: Multiplay
>   Differential Revision: https://reviews.freebsd.org/D4111
>
> Modified:
>   head/sys/net/if.c
>   head/sys/net/if_lagg.c
>   head/sys/net/if_lagg.h
>   head/sys/net/if_var.h
>   head/sys/netinet/if_ether.c
>   head/sys/netinet/if_ether.h
>   head/sys/netinet/in_var.h
>   head/sys/netinet/ip_carp.c
>   head/sys/netinet6/in6.c
>   head/sys/netinet6/in6_var.h
>   head/sys/netinet6/nd6.c
>   head/sys/netinet6/nd6.h
>   head/sys/netinet6/nd6_nbr.c
>
> Modified: head/sys/net/if.c
> ==
> --- head/sys/net/if.c Tue Dec 15 15:48:03 2015 (r292274)
> +++ head/sys/net/if.c Tue Dec 15 16:02:11 2015 (r292275)
> @@ -126,7 +126,7 @@ SX_SYSINIT(ifdescr_sx, _sx, "ifn
>
>  void (*bridge_linkstate_p)(struct ifnet *ifp);
>  void (*ng_ether_link_state_p)(struct ifnet *ifp, int state);
> -void (*lagg_linkstate_p)(struct ifnet *ifp, int state);
> +void (*lagg_linkstate_p)(struct ifnet *ifp);
>  /* These are external hooks for CARP. */
>  void (*carp_linkstate_p)(struct ifnet *ifp);
>  void (*carp_demote_adj_p)(int, char *);
> @@ -1984,6 +1984,8 @@ if_unroute(struct ifnet *ifp, int flag,
>
>  if (ifp->if_carp)
>  (*carp_linkstate_p)(ifp);
> + if (ifp->if_lagg)
> + (*lagg_linkstate_p)(ifp);
>  rt_ifmsg(ifp);
>  }
>
> @@ -2005,6 +2007,8 @@ if_route(struct ifnet *ifp, int flag, in
>  pfctlinput(PRC_IFUP, ifa->ifa_addr);
>  if (ifp->if_carp)
>  (*carp_linkstate_p)(ifp);
> + if (ifp->if_lagg)
> + (*lagg_linkstate_p)(ifp);
>  rt_ifmsg(ifp);
>  #ifdef INET6
>  in6_if_up(ifp);
> @@ -2019,17 +2023,27 @@ int (*vlan_tag_p)(struct ifnet *, uint16
>  int (*vlan_setcookie_p)(struct ifnet *, void *);
>  void *(*vlan_cookie_p)(struct ifnet *);
>
> +void
> +if_link_state_change(struct ifnet *ifp, int link_state)
> +{
> +
> + return if_link_state_change_cond(ifp, link_state, 0);
> +}
> +
>  /*
>   * Handle a change in the interface link state. To avoid LORs
>   * between driver lock and upper layer locks, as well as possible
>   * recursions, we post event to taskqueue, and all job
>   * is done in static do_link_state_change().
> + *
> + * If the current link state matches link_state and force isn't
> + * specified no action is taken.
>   */
>  void
> -if_link_state_change(struct ifnet *ifp, int link_state)
> +if_link_state_change_cond(struct ifnet *ifp, int link_state, int force)
>  {
> - /* Return if state hasn't changed. */
> - if (ifp->if_link_state == link_state)
> +
> + if (ifp->if_link_state == link_state && !force)
>  return;
>
>  ifp->if_link_state = link_state;
> @@ -2057,7 +2071,7 @@ do_link_state_change(void *arg, int pend
>  if (ifp->if_bridge)
>  (*bridge_linkstate_p)(ifp);
>  if (ifp->if_lagg)
> - (*lagg_linkstate_p)(ifp, link_state);
> + (*lagg_linkstate_p)(ifp);
>
>  if (IS_DEFAULT_VNET(curvnet))
>  devctl_notify("IFNET", ifp->if_xname,
>
> Modified: head/sys/net/if_lagg.c
> ==
> --- 

Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-16 Thread Steven Hartland

On 15/12/2015 22:58, Kristof Provost wrote:

On 15 Dec 2015, at 23:15, Kristof Provost  wrote:
Based on the arp_announce() in the backtrace this commit looks like a possible 
cause.

I see this in arp_announce():
KP: arp_announce() ifp->if_addr = 0

So that explains why we panic in 'lladdr = IF_LLADDR(ifp);’.

I’ve done a very quick hack:
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 2214542..9b25356 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1246,9 +1246,15 @@ arp_announce(struct ifnet *ifp)
 }
 IF_ADDR_RUNLOCK(ifp);

-   lladdr = IF_LLADDR(ifp);
-   for (i = 0; i < cnt; i++) {
-   arp_announce_addr(ifp, head + i, lladdr);
+   printf("KP: %s() ifp = %p\n", __FUNCTION__, ifp);
+   printf("KP: %s() ifp->if_addr = %p\n", __FUNCTION__, ifp->if_addr);
+
+   if (ifp->if_addr) {
+   printf("KP: %s() ifp->if_addr->ifa_addr = %p\n", __FUNCTION__, 
ifp->if_addr->ifa_addr);
+   lladdr = IF_LLADDR(ifp);
+   for (i = 0; i < cnt; i++) {
+   arp_announce_addr(ifp, head + i, lladdr);
+   }
 }
 free(head, M_TEMP);
  }

With this patch the device boots. I haven’t been able to verify if everything works because of 
a different issue ("Shared object "lib80211.so.1" not found, required by 
“ifconfig””, no doubt just a small problem with the freebsd-wifi-build scripts).

Regards,
Kristof

Thanks for all the info Kristof appreciated.

It seems really odd that you're getting a link up event for an interface 
that doesn't have a LLA, so I'm wondering if this is the result of an 
issue elsewhere which this change brings to light, its as though 
if_attach hasn't been called.


Looking at your trace the device seems to be an arswitch. If it never 
allocates a LLA to each port then maybe the more correct fix would be to 
ensure it IFF_NOARP in if_flags?


I've attached a patch which should fix if you could test that would be 
great, but I'd still like to understand if there is something wrong 
elsewhere before I do.


Regards
Steve


Index: sys/netinet/if_ether.c
===
--- sys/netinet/if_ether.c  (revision 292275)
+++ sys/netinet/if_ether.c  (working copy)
@@ -1209,7 +1209,8 @@ arp_announce(struct ifnet *ifp)
struct ifaddr *ifa;
struct in_addr *addr, *head;
 
-   if (!(ifp->if_flags & IFF_UP) || (ifp->if_flags & IFF_NOARP))
+   if (!(ifp->if_flags & IFF_UP) || (ifp->if_flags & IFF_NOARP) ||
+   ifp->if_addr == NULL)
return;
 
entries = 8;
@@ -1246,9 +1247,11 @@ arp_announce(struct ifnet *ifp)
}
IF_ADDR_RUNLOCK(ifp);
 
-   lladdr = IF_LLADDR(ifp);
-   for (i = 0; i < cnt; i++) {
-   arp_announce_addr(ifp, head + i, lladdr);
+   if (cnt > 0) {
+   lladdr = IF_LLADDR(ifp);
+   for (i = 0; i < cnt; i++) {
+   arp_announce_addr(ifp, head + i, lladdr);
+   }
}
free(head, M_TEMP);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-16 Thread Steven Hartland

On 16/12/2015 09:02, Alexander V. Chernikov wrote:

15.12.2015, 19:02, "Steven Hartland" :

Author: smh
Date: Tue Dec 15 16:02:11 2015
New Revision: 292275
URL: https://svnweb.freebsd.org/changeset/base/292275

Log:
   Fix lagg failover due to missing notifications

   When using lagg failover mode neither Gratuitous ARP (IPv4) or Unsolicited
   Neighbour Advertisements (IPv6) are sent to notify other nodes that the
   address may have moved.

   This results is slow failover, dropped packets and network outages for the
   lagg interface when the primary link goes down.

   We now use the new if_link_state_change_cond with the force param set to
   allow lagg to force through link state changes and hence fire a
   ifnet_link_event which are now monitored by rip and nd6.

   Upon receiving these events each protocol trigger the relevant
   notifications:
   * inet4 => Gratuitous ARP
   * inet6 => Unsolicited Neighbour Announce

Steven, I believe that having DELAY() called inside callout routine is 
incorrect - you are delaying other consumers for arbitrary amount of time.
If you really want to do it that way you should create separate taskqueue for 
that.
Also, destroying interface while doing these DELAYs would very likely crash the 
system
:"#define IN6_MAX_ANYCAST_DELAY_TIME_MS 100" is misguiding
There are some style(9) issues like lack of empty line between nd6_init() and 
nd6_ifnet_link_event()
...
Thanks Alexander, do you think an acceptable workaround for the time 
being is to remove the DELAY, until I get some time to work on a taskqueue?


Also do you have any input on the questions I raised about Kristof's 
panic due to NULL ifp->if_addr arp_announce?

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-16 Thread Kristof Provost

> On 16 Dec 2015, at 00:08, Adrian Chadd  wrote:
> 
> oops, file a bug at github.com/freebsd/freebsd-wifi-build and I'll fix it 
> asap.
> 
No worries, it happens:
https://github.com/freebsd/freebsd-wifi-build/issues/68

This fixed the problem for me:
diff --git a/build/bin/build_mfsroot b/build/bin/build_mfsroot
index 2c1f0f4..733f1fb 100755
--- a/build/bin/build_mfsroot
+++ b/build/bin/build_mfsroot
@@ -267,6 +267,7 @@ ${INSTALL_DEF_FILE} ${X_BASEDIR}/files/pf.conf 
${X_STAGING_FSROOT}/c/etc/

 # networking
 ${INSTALL_DEF_BIN} ${X_DESTDIR}/sbin/ifconfig ${X_STAGING_FSROOT}/sbin/
+${INSTALL_DEF_LIB} ${X_DESTDIR}/lib/lib80211.so.1 ${X_STAGING_FSROOT}/lib
 ${INSTALL_DEF_BIN} ${X_DESTDIR}/sbin/route ${X_STAGING_FSROOT}/sbin/
 ${INSTALL_DEF_BIN} ${X_DESTDIR}/sbin/ping ${X_STAGING_FSROOT}/sbin/
 ${INSTALL_DEF_BIN} ${X_DESTDIR}/sbin/ping6 ${X_STAGING_FSROOT}/sbin/


Steven,

With this patch and the hack in my previous e-mail my TPLink boots correctly 
and works as expected.

Regards,
Kristof
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-15 Thread Adrian Chadd
oops, file a bug at github.com/freebsd/freebsd-wifi-build and I'll fix it asap.


-a
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-15 Thread Kristof Provost

> On 15 Dec 2015, at 23:15, Kristof Provost  wrote:
> Based on the arp_announce() in the backtrace this commit looks like a 
> possible cause.
I see this in arp_announce(): 
KP: arp_announce() ifp->if_addr = 0

So that explains why we panic in 'lladdr = IF_LLADDR(ifp);’.

I’ve done a very quick hack:
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 2214542..9b25356 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -1246,9 +1246,15 @@ arp_announce(struct ifnet *ifp)
}
IF_ADDR_RUNLOCK(ifp);

-   lladdr = IF_LLADDR(ifp);
-   for (i = 0; i < cnt; i++) {
-   arp_announce_addr(ifp, head + i, lladdr);
+   printf("KP: %s() ifp = %p\n", __FUNCTION__, ifp);
+   printf("KP: %s() ifp->if_addr = %p\n", __FUNCTION__, ifp->if_addr);
+
+   if (ifp->if_addr) {
+   printf("KP: %s() ifp->if_addr->ifa_addr = %p\n", __FUNCTION__, 
ifp->if_addr->ifa_addr);
+   lladdr = IF_LLADDR(ifp);
+   for (i = 0; i < cnt; i++) {
+   arp_announce_addr(ifp, head + i, lladdr);
+   }
}
free(head, M_TEMP);
 }

With this patch the device boots. I haven’t been able to verify if everything 
works because of a different issue ("Shared object "lib80211.so.1" not found, 
required by “ifconfig””, no doubt just a small problem with the 
freebsd-wifi-build scripts).

Regards,
Kristof
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r292275 - in head/sys: net netinet netinet6

2015-12-15 Thread Kristof Provost

> On 15 Dec 2015, at 17:02, Steven Hartland  wrote:
> 
> Author: smh
> Date: Tue Dec 15 16:02:11 2015
> New Revision: 292275
> URL: https://svnweb.freebsd.org/changeset/base/292275
> 
> Log:
>  Fix lagg failover due to missing notifications
> 

I’ve just built a new image (r292287-based) for my TPLink tl-wdr3600 device, 
and see the following panic:

uhub0: 1 port with 1 removable, self powered
random: harvesting attach, 8 bytes (4 bits) from uhub0
arswitch0: arswitch_miipollstat: port 1: port -> UP
arswitch0port2: link state changed to UP
Trap cause = 2 (TLB miss (load or instr. fetch) - kernel mode)
[ thread pid 11 tid 100017 ]
Stopped at  arp_announce+0x134: lw  v0,0(v0)
db> bt
Tracing pid 11 tid 100017 td 0x80a746c0
db_trace_thread+30 (?,?,?,?) ra c462b8b00018 sp 0 sz 0
8008c520+114 (0,?,,?) ra c462b8c80020 sp 1 sz 1
8008b864+388 (?,?,?,?) ra c462b8e800a8 sp 0 sz 0
db_command_loop+70 (?,?,?,?) ra c462b9900018 sp 0 sz 0
8008e438+f4 (?,?,?,?) ra c462b9a801a8 sp 0 sz 0
kdb_trap+100 (?,?,?,?) ra c462bb500030 sp 0 sz 0
trap+fac (?,?,?,?) ra c462bb8000c0 sp 0 sz 0
MipsKernGenException+ec (1,80a746c0,8049fcf8,4df) ra c462bc4000c8 sp 
10001 sz 1
arp_announce+134 (?,?,?,?) ra c462bd080030 sp 0 sz 0
8031d868+2c (?,?,?,?) ra c462bd380018 sp 0 sz 0
802b7e40+1fc (?,?,?,?) ra c462bd500028 sp 0 sz 0
8022bc8c+f0 (?,?,?,?) ra c462bd780040 sp 0 sz 0
taskqueue_run+58 (?,?,?,?) ra c462bdb80018 sp 0 sz 0
8022bf5c+18 (?,?,?,?) ra c462bdd00018 sp 0 sz 0
intr_event_execute_handlers+158 (?,?,?,?) ra c462bde80028 sp 0 sz 0
801ad9a0+c4 (?,?,?,?) ra c462be100048 sp 0 sz 0
fork_exit+b0 (?,?,?,?) ra c462be580028 sp 0 sz 0
fork_trampoline+10 (?,?,?,?) ra c462be80 sp 0 sz 0
pid 11

Based on the arp_announce() in the backtrace this commit looks like a possible 
cause.

I’ll take a look and see what I can figure out, but if something pops out for 
you please let me know

Regards,
Kristof
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"