Module Name: src
Committed By: ozaki-r
Date: Mon Jul 28 14:24:48 UTC 2014
Modified Files:
src/sys/net: if.c if_ether.h if_ethersubr.c
Log Message:
Add a mutex for global variables of if_ethersubr.c
To initialize the mutex, we introduce etherinit that is called from ifinit1.
To generate a diff of this commit:
cvs rdiff -u -r1.285 -r1.286 src/sys/net/if.c
cvs rdiff -u -r1.63 -r1.64 src/sys/net/if_ether.h
cvs rdiff -u -r1.202 -r1.203 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.c
diff -u src/sys/net/if.c:1.285 src/sys/net/if.c:1.286
--- src/sys/net/if.c:1.285 Tue Jul 1 10:16:02 2014
+++ src/sys/net/if.c Mon Jul 28 14:24:48 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: if.c,v 1.285 2014/07/01 10:16:02 ozaki-r Exp $ */
+/* $NetBSD: if.c,v 1.286 2014/07/28 14:24:48 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.285 2014/07/01 10:16:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.286 2014/07/28 14:24:48 ozaki-r Exp $");
#include "opt_inet.h"
@@ -252,6 +252,8 @@ ifinit1(void)
if_pfil = pfil_head_create(PFIL_TYPE_IFNET, NULL);
KASSERT(if_pfil != NULL);
+
+ etherinit();
}
ifnet_t *
Index: src/sys/net/if_ether.h
diff -u src/sys/net/if_ether.h:1.63 src/sys/net/if_ether.h:1.64
--- src/sys/net/if_ether.h:1.63 Tue Jun 10 09:38:30 2014
+++ src/sys/net/if_ether.h Mon Jul 28 14:24:48 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ether.h,v 1.63 2014/06/10 09:38:30 joerg Exp $ */
+/* $NetBSD: if_ether.h,v 1.64 2014/07/28 14:24:48 ozaki-r Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -324,6 +324,7 @@ vlan_input_tag(struct ifnet *ifp, struct
/* test if any VLAN is configured for this interface */
#define VLAN_ATTACHED(ec) ((ec)->ec_nvlans > 0)
+void etherinit(void);
void ether_ifattach(struct ifnet *, const uint8_t *);
void ether_ifdetach(struct ifnet *);
int ether_mediachange(struct ifnet *);
Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.202 src/sys/net/if_ethersubr.c:1.203
--- src/sys/net/if_ethersubr.c:1.202 Mon Jun 30 10:03:41 2014
+++ src/sys/net/if_ethersubr.c Mon Jul 28 14:24:48 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ethersubr.c,v 1.202 2014/06/30 10:03:41 ozaki-r Exp $ */
+/* $NetBSD: if_ethersubr.c,v 1.203 2014/07/28 14:24:48 ozaki-r 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.202 2014/06/30 10:03:41 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.203 2014/07/28 14:24:48 ozaki-r Exp $");
#include "opt_inet.h"
#include "opt_atalk.h"
@@ -175,6 +175,7 @@ extern u_char aarp_org_code[3];
static struct timeval bigpktppslim_last;
static int bigpktppslim = 2; /* XXX */
static int bigpktpps_count;
+static kmutex_t bigpktpps_lock __cacheline_aligned;
const uint8_t etherbroadcastaddr[ETHER_ADDR_LEN] =
@@ -603,11 +604,13 @@ ether_input(struct ifnet *ifp, struct mb
*/
if (etype != ETHERTYPE_MPLS && m->m_pkthdr.len >
ETHER_MAX_FRAME(ifp, etype, m->m_flags & M_HASFCS)) {
+ mutex_enter(&bigpktpps_lock);
if (ppsratecheck(&bigpktppslim_last, &bigpktpps_count,
bigpktppslim)) {
printf("%s: discarding oversize frame (len=%d)\n",
ifp->if_xname, m->m_pkthdr.len);
}
+ mutex_exit(&bigpktpps_lock);
m_freem(m);
return;
}
@@ -1532,3 +1535,9 @@ SYSCTL_SETUP(sysctl_net_ether_setup, "sy
ether_multicast_sysctl, 0, NULL, 0,
CTL_CREATE, CTL_EOL);
}
+
+void
+etherinit(void)
+{
+ mutex_init(&bigpktpps_lock, MUTEX_DEFAULT, IPL_NET);
+}