NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: kern/57645: bridge does not work on raspberry pi



The following reply was made to PR kern/57645; it has been noted by GNATS.

From: mlelstv%serpens.de@localhost (Michael van Elst)
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/57645: bridge does not work on raspberry pi
Date: Sun, 8 Oct 2023 10:46:29 -0000 (UTC)

 mlelstv%serpens.de@localhost (Michael van Elst) writes:
 
 >The following reply was made to PR kern/57645; it has been noted by GNATS.
 
 >From: mlelstv%serpens.de@localhost (Michael van Elst)
 >To: gnats-bugs%netbsd.org@localhost
 >Cc: 
 >Subject: Re: kern/57645: bridge does not work on raspberry pi
 >Date: Sat, 7 Oct 2023 15:04:05 -0000 (UTC)
 
 > sc.dying%gmail.com@localhost writes:
 > 
 > >	On my testbed (see How-To-Repeat section), tcpdump shows
 > >	only broadcast/multicast packets on both interfaces, but
 > >	unicast packets are not observed.
 > 
 > I can replicate this with an axen(4) and the builtin usmsc(4) device.
 > 
 > The underlying problem is that the promiscous mode works for neither
 > device (completely without bridge).
 > 
 > In the bridge setup this means that only broadcast/multicast packets
 > work or those destined for the mac address of the interface itself.
 > 
 
 
 The usbnet code has also an inverted logic on when to change settings
 so that it effectively never takes place. The following patch works
 for me:
 
 
 Index: sys/dev/usb/usbnet.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/usbnet.c,v
 retrieving revision 1.114
 diff -p -u -r1.114 usbnet.c
 --- sys/dev/usb/usbnet.c	15 Jul 2023 21:41:26 -0000	1.114
 +++ sys/dev/usb/usbnet.c	8 Oct 2023 10:40:10 -0000
 @@ -1012,7 +1012,7 @@ usbnet_ifflags_cb(struct ethercom *ec)
  	KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
  
  	const u_short changed = ifp->if_flags ^ unp->unp_if_flags;
 -	if ((changed & ~(IFF_CANTCHANGE | IFF_DEBUG)) == 0) {
 +	if ((changed & ~(IFF_CANTCHANGE | IFF_DEBUG)) != 0) {
  		mutex_enter(&unp->unp_mcastlock);
  		unp->unp_if_flags = ifp->if_flags;
  		mutex_exit(&unp->unp_mcastlock);
 @@ -1030,8 +1030,6 @@ usbnet_ifflags_cb(struct ethercom *ec)
  		 */
  		if (changed & IFF_PROMISC)
  			rv = ENETRESET;
 -	} else {
 -		rv = ENETRESET;
  	}
  
  	return rv;
 @@ -1065,23 +1063,23 @@ usbnet_if_ioctl(struct ifnet *ifp, u_lon
  
  	error = ether_ioctl(ifp, cmd, data);
  	if (error == ENETRESET) {
 +		/*
 +		 * If there's a hardware multicast filter, and
 +		 * it has been programmed by usbnet_init_rx_tx
 +		 * and is active, update it now.  Otherwise,
 +		 * drop the update on the floor -- it will be
 +		 * observed by usbnet_init_rx_tx next time we
 +		 * bring the interface up.
 +		 */
 +		if (un->un_ops->uno_mcast) {
 +			mutex_enter(&unp->unp_mcastlock);
 +			if (unp->unp_mcastactive)
 +				(*un->un_ops->uno_mcast)(ifp);
 +			mutex_exit(&unp->unp_mcastlock);
 +		}
  		switch (cmd) {
  		case SIOCADDMULTI:
  		case SIOCDELMULTI:
 -			/*
 -			 * If there's a hardware multicast filter, and
 -			 * it has been programmed by usbnet_init_rx_tx
 -			 * and is active, update it now.  Otherwise,
 -			 * drop the update on the floor -- it will be
 -			 * observed by usbnet_init_rx_tx next time we
 -			 * bring the interface up.
 -			 */
 -			if (un->un_ops->uno_mcast) {
 -				mutex_enter(&unp->unp_mcastlock);
 -				if (unp->unp_mcastactive)
 -					(*un->un_ops->uno_mcast)(ifp);
 -				mutex_exit(&unp->unp_mcastlock);
 -			}
  			error = 0;
  			break;
  		default:
 @@ -1306,8 +1304,16 @@ usbnet_if_init(struct ifnet *ifp)
  	 * analysis -- and possibly some tweaking -- of sys/net to
  	 * ensure.
  	 */
 -	if (ifp->if_flags & IFF_RUNNING)
 +	if (ifp->if_flags & IFF_RUNNING) {
 +		if (un->un_ops->uno_mcast) {
 +			struct usbnet_private * const unp __unused = un->un_pri;
 +			mutex_enter(&unp->unp_mcastlock);
 +			(*un->un_ops->uno_mcast)(ifp);
 +			unp->unp_mcastactive = true;
 +			mutex_exit(&unp->unp_mcastlock);
 +		}
  		return 0;
 +	}
  
  	error = uno_init(un, ifp);
  	if (error)
 
 


Home | Main Index | Thread Index | Old Index