Thank you, you can find enclosed a patch following your suggestion.

----- Le 8 Juin 16, à 22:40, Eric Joyner ricer...@gmail.com a écrit :

> I think a better fix here is to have the driver not call init_locked() when
> the driver is not running when setting the MTU.
> 
> It looks like all the other Intel network drivers do the same thing as this
> for the MTU.
> 
> On Wed, Jun 8, 2016 at 2:47 AM Arnaud YSMAL <arnaud.ys...@stormshield.eu>
> wrote:
> 
>> Hi,
>>
>> Configuring the network card with the following commands (in this specific
>> order) does not work.
>> # ifconfig em0 down
>> # ifconfig em0 mtu 1500
>> # ifconfig em0 ether 12:34:56:12:34:56
>> # ifconfig em0 192.168.1.1/24
>> # ifconfig em0 up
>>
>> I was able to reproduce this issue on 10.3-RELEASE and HEAD with ix and em
>> drivers.
>>
>> From what I understand:
>> - When setting the mtu, the driver calls the init of the interface which
>> sets the IFF_DRV_RUNNING flag
>> - When setting the mac address, if_setlladdr (from if.c) copy the mac
>> address but does nothing else (the interface is not up)
>> - When setting the ip address, the driver does not call the init as the
>> IFF_DRV_RUNNING is already set.
>> - When setting the up flag, same as above, the IFF_DRV_RUNNING is already
>> set.
>>
>> In this case the network card does not work as the mac address filter is
>> not up to date.
>>
>> The enclosed path fixes this issue,
>> It changes if_setlladdr in if.c to call the ifp->if_ioctl function with
>> the IFF_UP flag clear even when the interface is not up.
>> The driver will then call its stop function which clear the
>> IFF_DRV_RUNNING.
>> The init will be called when setting the ip address or the up flag.
>>
>> Do you have any advice regarding this patch?
>>
>> Arnaud_______________________________________________
>> freebsd-net@freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/freebsd-net
> > To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 14f5463..ddd651d 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -1214,7 +1214,8 @@ em_ioctl(if_t ifp, u_long command, caddr_t data)
 		if_setmtu(ifp, ifr->ifr_mtu);
 		adapter->hw.mac.max_frame_size =
 		    if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN;
-		em_init_locked(adapter);
+		if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
+			em_init_locked(adapter);
 		EM_CORE_UNLOCK(adapter);
 		break;
 	    }
diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c
index 83e1e83..ef5256f 100644
--- a/sys/dev/e1000/if_igb.c
+++ b/sys/dev/e1000/if_igb.c
@@ -1106,7 +1106,8 @@ igb_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 		ifp->if_mtu = ifr->ifr_mtu;
 		adapter->max_frame_size =
 		    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
-		igb_init_locked(adapter);
+		if ((ifp->if_drv_flags & IFF_DRV_RUNNING))
+			igb_init_locked(adapter);
 		IGB_CORE_UNLOCK(adapter);
 		break;
 	    }
diff --git a/sys/dev/e1000/if_lem.c b/sys/dev/e1000/if_lem.c
index 50b2cb0..55b8310 100644
--- a/sys/dev/e1000/if_lem.c
+++ b/sys/dev/e1000/if_lem.c
@@ -1053,7 +1053,8 @@ lem_ioctl(if_t ifp, u_long command, caddr_t data)
 		if_setmtu(ifp, ifr->ifr_mtu);
 		adapter->max_frame_size =
 		    if_getmtu(ifp) + ETHER_HDR_LEN + ETHER_CRC_LEN;
-		lem_init_locked(adapter);
+		if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING))
+			lem_init_locked(adapter);
 		EM_CORE_UNLOCK(adapter);
 		break;
 	    }
diff --git a/sys/dev/ixgb/if_ixgb.c b/sys/dev/ixgb/if_ixgb.c
index 4ef4929..4db272c 100644
--- a/sys/dev/ixgb/if_ixgb.c
+++ b/sys/dev/ixgb/if_ixgb.c
@@ -539,7 +539,8 @@ ixgb_ioctl(struct ifnet * ifp, IOCTL_CMD_TYPE command, caddr_t data)
 			adapter->hw.max_frame_size =
 				ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
 
-			ixgb_init_locked(adapter);
+			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+				ixgb_init_locked(adapter);
 			IXGB_UNLOCK(adapter);
 		}
 		break;
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index ddee699..cf2231d 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -893,7 +893,8 @@ ixgbe_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
 			ifp->if_mtu = ifr->ifr_mtu;
 			adapter->max_frame_size =
 				ifp->if_mtu + IXGBE_MTU_HDR;
-			ixgbe_init_locked(adapter);
+			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+				ixgbe_init_locked(adapter);
 #ifdef PCI_IOV
 			ixgbe_recalculate_max_frame(adapter);
 #endif
diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c
index 13c2bef..80fb1b3 100644
--- a/sys/dev/ixgbe/if_ixv.c
+++ b/sys/dev/ixgbe/if_ixv.c
@@ -578,7 +578,8 @@ ixv_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
 			ifp->if_mtu = ifr->ifr_mtu;
 			adapter->max_frame_size =
 				ifp->if_mtu + IXGBE_MTU_HDR;
-			ixv_init_locked(adapter);
+			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+				ixv_init_locked(adapter);
 			IXGBE_CORE_UNLOCK(adapter);
 		}
 		break;
diff --git a/sys/dev/ixl/if_ixl.c b/sys/dev/ixl/if_ixl.c
index d759cfd..8e9ba80 100644
--- a/sys/dev/ixl/if_ixl.c
+++ b/sys/dev/ixl/if_ixl.c
@@ -980,7 +980,8 @@ ixl_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
 			vsi->max_frame_size =
 				ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN
 			    + ETHER_VLAN_ENCAP_LEN;
-			ixl_init_locked(pf);
+			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+				ixl_init_locked(pf);
 			IXL_PF_UNLOCK(pf);
 		}
 		break;
diff --git a/sys/dev/ixl/if_ixlv.c b/sys/dev/ixl/if_ixlv.c
index 9e5242c..9be8a36 100644
--- a/sys/dev/ixl/if_ixlv.c
+++ b/sys/dev/ixl/if_ixlv.c
@@ -676,7 +676,8 @@ ixlv_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
 			vsi->max_frame_size =
 			    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN
 			    + ETHER_VLAN_ENCAP_LEN;
-			ixlv_init_locked(sc);
+			if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+				ixlv_init_locked(sc);
 		}
 		mtx_unlock(&sc->mtx);
 		break;
_______________________________________________
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to