Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Check if VLAN ID isn't duplicated on a same parent i...
details: https://anonhg.NetBSD.org/src/rev/54d45f59a614
branches: trunk
changeset: 356760:54d45f59a614
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Wed Oct 11 08:10:00 2017 +0000
description:
Check if VLAN ID isn't duplicated on a same parent interface and return
EEXIST if it failed.
diffstat:
sys/net/if_vlan.c | 33 ++++++++++++++++++++++++++++++---
1 files changed, 30 insertions(+), 3 deletions(-)
diffs (86 lines):
diff -r 1ac5eb377e24 -r 54d45f59a614 sys/net/if_vlan.c
--- a/sys/net/if_vlan.c Wed Oct 11 06:49:03 2017 +0000
+++ b/sys/net/if_vlan.c Wed Oct 11 08:10:00 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_vlan.c,v 1.100 2017/09/26 07:42:06 knakahara Exp $ */
+/* $NetBSD: if_vlan.c,v 1.101 2017/10/11 08:10:00 msaitoh Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.100 2017/09/26 07:42:06 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.101 2017/10/11 08:10:00 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -386,10 +386,12 @@
struct ifnet *ifp = &ifv->ifv_if;
struct ifvlan_linkmib *nmib = NULL;
struct ifvlan_linkmib *omib = NULL;
+ struct ifvlan_linkmib *checkmib = NULL;
struct psref_target *nmib_psref = NULL;
int error = 0;
int idx;
bool omib_cleanup = false;
+ struct psref psref;
nmib = kmem_alloc(sizeof(*nmib), KM_SLEEP);
@@ -401,6 +403,14 @@
goto done;
}
+ /* Duplicate check */
+ checkmib = vlan_lookup_tag_psref(p, tag, &psref);
+ if (checkmib != NULL) {
+ vlan_putref_linkmib(checkmib, &psref);
+ error = EEXIST;
+ goto done;
+ }
+
*nmib = *omib;
nmib_psref = &nmib->ifvm_psref;
@@ -410,6 +420,7 @@
case IFT_ETHER:
{
struct ethercom *ec = (void *) p;
+ struct vlanidlist *vidmem;
nmib->ifvm_msw = &vlan_ether_multisw;
nmib->ifvm_encaplen = ETHER_VLAN_ENCAP_LEN;
nmib->ifvm_mintu = ETHERMIN;
@@ -433,7 +444,14 @@
}
error = 0;
}
-
+ vidmem = kmem_alloc(sizeof(struct vlanidlist), KM_SLEEP);
+ if (vidmem == NULL){
+ ec->ec_nvlans--;
+ error = ENOMEM;
+ goto done;
+ }
+ vidmem->vid = tag;
+ SLIST_INSERT_HEAD(&ec->ec_vids, vidmem, vid_list);
/*
* If the parent interface can do hardware-assisted
* VLAN encapsulation, then propagate its hardware-
@@ -555,6 +573,15 @@
case IFT_ETHER:
{
struct ethercom *ec = (void *)p;
+ struct vlanidlist *vlanidp, *tmpp;
+
+ SLIST_FOREACH_SAFE(vlanidp, &ec->ec_vids, vid_list, tmpp) {
+ if (vlanidp->vid == nmib->ifvm_tag) {
+ SLIST_REMOVE(&ec->ec_vids, vlanidp, vlanidlist,
+ vid_list);
+ kmem_free(vlanidp, sizeof(*vlanidp));
+ }
+ }
if (--ec->ec_nvlans == 0)
(void)ether_disable_vlan_mtu(p);
Home |
Main Index |
Thread Index |
Old Index