Module Name:    src
Committed By:   martin
Date:           Thu Mar  8 14:37:58 UTC 2018

Modified Files:
        src/sys/net [netbsd-8]: if_ethersubr.c

Log Message:
Pull up following revision(s) (requested by msaitoh in ticket #618):
        sys/net/if_ethersubr.c: revision 1.245
        sys/net/if_ethersubr.c: revision 1.247

  Use macro(ETHER_LOCK() and ETHER_UNLOCK()). No functional change.

- Modify ether_ioctl() for readability. No functional change.

- KNF


To generate a diff of this commit:
cvs rdiff -u -r1.242.6.3 -r1.242.6.4 src/sys/net/if_ethersubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.242.6.3 src/sys/net/if_ethersubr.c:1.242.6.4
--- src/sys/net/if_ethersubr.c:1.242.6.3	Tue Jan  9 19:23:04 2018
+++ src/sys/net/if_ethersubr.c	Thu Mar  8 14:37:58 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.242.6.3 2018/01/09 19:23:04 snj Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.242.6.4 2018/03/08 14:37:58 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.242.6.3 2018/01/09 19:23:04 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.242.6.4 2018/03/08 14:37:58 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -226,13 +226,13 @@ ether_output(struct ifnet * const ifp0, 
 		ifp = ifp->if_carpdev;
 		/* ac = (struct arpcom *)ifp; */
 
-		if ((ifp0->if_flags & (IFF_UP|IFF_RUNNING)) !=
-		    (IFF_UP|IFF_RUNNING))
+		if ((ifp0->if_flags & (IFF_UP | IFF_RUNNING)) !=
+		    (IFF_UP | IFF_RUNNING))
 			senderr(ENETDOWN);
 	}
 #endif /* NCARP > 0 */
 
-	if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
+	if ((ifp->if_flags & (IFF_UP | IFF_RUNNING)) != (IFF_UP | IFF_RUNNING))
 		senderr(ENETDOWN);
 
 	switch (dst->sa_family) {
@@ -640,7 +640,7 @@ ether_input(struct ifnet *ifp, struct mb
 			return;
 	}
 #endif /* NCARP > 0 */
-	if ((m->m_flags & (M_BCAST|M_MCAST|M_PROMISC)) == 0 &&
+	if ((m->m_flags & (M_BCAST | M_MCAST | M_PROMISC)) == 0 &&
 	    (ifp->if_flags & IFF_PROMISC) != 0 &&
 	    memcmp(CLLADDR(ifp->if_sadl), eh->ether_dhost,
 		   ETHER_ADDR_LEN) != 0) {
@@ -1005,13 +1005,13 @@ ether_ifdetach(struct ifnet *ifp)
 		vlan_ifdetach(ifp);
 #endif
 
-	mutex_enter(ec->ec_lock);
+	ETHER_LOCK(ec);
 	while ((enm = LIST_FIRST(&ec->ec_multiaddrs)) != NULL) {
 		LIST_REMOVE(enm, enm_list);
 		kmem_intr_free(enm, sizeof(*enm));
 		ec->ec_multicnt--;
 	}
-	mutex_exit(ec->ec_lock);
+	ETHER_UNLOCK(ec);
 
 	mutex_destroy(ec->ec_lock);
 
@@ -1231,7 +1231,7 @@ ether_addmulti(const struct sockaddr *sa
 	if (enm == NULL)
 		return ENOBUFS;
 
-	mutex_enter(ec->ec_lock);
+	ETHER_LOCK(ec);
 	error = ether_multiaddr(sa, addrlo, addrhi);
 	if (error != 0)
 		goto out;
@@ -1270,7 +1270,7 @@ ether_addmulti(const struct sockaddr *sa
 	error = ENETRESET;
 	enm = NULL;
 out:
-	mutex_exit(ec->ec_lock);
+	ETHER_UNLOCK(ec);
 	if (enm != NULL)
 		kmem_intr_free(enm, sizeof(*enm));
 	return error;
@@ -1287,7 +1287,7 @@ ether_delmulti(const struct sockaddr *sa
 	u_char addrhi[ETHER_ADDR_LEN];
 	int error;
 
-	mutex_enter(ec->ec_lock);
+	ETHER_LOCK(ec);
 	error = ether_multiaddr(sa, addrlo, addrhi);
 	if (error != 0)
 		goto error;
@@ -1312,7 +1312,7 @@ ether_delmulti(const struct sockaddr *sa
 	 */
 	LIST_REMOVE(enm, enm_list);
 	ec->ec_multicnt--;
-	mutex_exit(ec->ec_lock);
+	ETHER_UNLOCK(ec);
 
 	kmem_intr_free(enm, sizeof(*enm));
 	/*
@@ -1321,7 +1321,7 @@ ether_delmulti(const struct sockaddr *sa
 	 */
 	return ENETRESET;
 error:
-	mutex_exit(ec->ec_lock);
+	ETHER_UNLOCK(ec);
 	return error;
 }
 
@@ -1351,8 +1351,8 @@ ether_ioctl(struct ifnet *ifp, u_long cm
 	    {
 		struct ifaddr *ifa = (struct ifaddr *)data;
 		if (ifa->ifa_addr->sa_family != AF_LINK
-		    && (ifp->if_flags & (IFF_UP|IFF_RUNNING)) !=
-		       (IFF_UP|IFF_RUNNING)) {
+		    && (ifp->if_flags & (IFF_UP | IFF_RUNNING)) !=
+		       (IFF_UP | IFF_RUNNING)) {
 			ifp->if_flags |= IFF_UP;
 			if ((error = (*ifp->if_init)(ifp)) != 0)
 				return error;
@@ -1387,7 +1387,7 @@ ether_ioctl(struct ifnet *ifp, u_long cm
 	case SIOCSIFFLAGS:
 		if ((error = ifioctl_common(ifp, cmd, data)) != 0)
 			return error;
-		switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) {
+		switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
 		case IFF_RUNNING:
 			/*
 			 * If interface is marked down and it is running,
@@ -1401,18 +1401,21 @@ ether_ioctl(struct ifnet *ifp, u_long cm
 			 * start it.
 			 */
 			return (*ifp->if_init)(ifp);
-		case IFF_UP|IFF_RUNNING:
+		case IFF_UP | IFF_RUNNING:
 			error = 0;
-			if (ec->ec_ifflags_cb == NULL ||
-			    (error = (*ec->ec_ifflags_cb)(ec)) == ENETRESET) {
-				/*
-				 * Reset the interface to pick up
-				 * changes in any other flags that
-				 * affect the hardware state.
-				 */
-				return (*ifp->if_init)(ifp);
-			} else 
-				return error;
+			if (ec->ec_ifflags_cb != NULL) {
+				error = (*ec->ec_ifflags_cb)(ec);
+				if (error == ENETRESET) {
+					/*
+					 * Reset the interface to pick up
+					 * changes in any other flags that
+					 * affect the hardware state.
+					 */
+					return (*ifp->if_init)(ifp);
+				}
+			} else
+				error = (*ifp->if_init)(ifp);
+			return error;
 		case 0:
 			break;
 		}
@@ -1556,10 +1559,10 @@ retry:
 	multicnt = ec->ec_multicnt;
 	addrs = kmem_alloc(sizeof(*addrs) * multicnt, KM_SLEEP);
 
-	mutex_enter(ec->ec_lock);
+	ETHER_LOCK(ec);
 	if (multicnt < ec->ec_multicnt) {
 		/* The number of multicast addresses have increased */
-		mutex_exit(ec->ec_lock);
+		ETHER_UNLOCK(ec);
 		kmem_free(addrs, sizeof(*addrs) * multicnt);
 		goto retry;
 	}
@@ -1572,7 +1575,7 @@ retry:
 		memcpy(addr->enm_addrhi, enm->enm_addrhi, ETHER_ADDR_LEN);
 		i++;
 	}
-	mutex_exit(ec->ec_lock);
+	ETHER_UNLOCK(ec);
 
 	error = 0;
 	written = 0;

Reply via email to