FreeBSD Bugzilla – Attachment 260362 Details for
Bug 286755
[NEW PORT] net/ngvlan: Sets up/tears down VLAN interfaces using Netgraph
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
the port patch
0001-new-port-net-ngvlan.patch (text/plain), 7.03 KB, created by
Eugene M. Kim
on 2025-05-12 21:39:36 UTC
(
hide
)
Description:
the port patch
Filename:
MIME Type:
Creator:
Eugene M. Kim
Created:
2025-05-12 21:39:36 UTC
Size:
7.03 KB
patch
obsolete
>From 98a48ee11fb323e3e406e3d2819f28a78e827fd4 Mon Sep 17 00:00:00 2001 >From: Eugene Kim <ab@astral.blue> >Date: Mon, 12 May 2025 21:28:08 +0000 >Subject: [PATCH] new port: net/ngvlan > >`ngvlan` is FreeBSD rc.d script that sets up/tears down VLAN interfaces using >Netgraph. Unlike the traditional `vlan(4)`, `ngvlan` allows forwarding >untagged VLAN (often the management VLAN) traffic to a `bridge(4)` interface. >--- > net/ngvlan/Makefile | 26 ++++++++ > net/ngvlan/files/README.md | 61 +++++++++++++++++++ > net/ngvlan/files/ngvlan.in | 118 +++++++++++++++++++++++++++++++++++++ > net/ngvlan/pkg-descr | 3 + > 4 files changed, 208 insertions(+) > create mode 100644 net/ngvlan/Makefile > create mode 100644 net/ngvlan/files/README.md > create mode 100755 net/ngvlan/files/ngvlan.in > create mode 100644 net/ngvlan/pkg-descr > >diff --git a/net/ngvlan/Makefile b/net/ngvlan/Makefile >new file mode 100644 >index 000000000..77840870e >--- /dev/null >+++ b/net/ngvlan/Makefile >@@ -0,0 +1,26 @@ >+PORTNAME= ngvlan >+PORTVERSION= 0.1.0 >+CATEGORIES= net >+DISTFILES= >+ >+MAINTAINER= ab@astral.blue >+COMMENT= Sets up/tears down VLAN interfaces using Netgraph >+ >+LICENSE= MIT >+ >+USE_RC_SUBR= ngvlan >+PORTDOCS= README.md >+ >+NO_FETCH= yes >+NO_BUILD= yes >+NO_INSTALL= yes >+NO_TEST= yes >+NO_ARCH= yes >+ >+PLIST_FILES= ${DOCSDIR_REL}/README.md >+ >+post-install: >+ ${MKDIR} ${STAGEDIR}${DOCSDIR} >+ ${INSTALL_DATA} ${FILESDIR}/README.md ${STAGEDIR}${DOCSDIR} >+ >+.include <bsd.port.mk> >diff --git a/net/ngvlan/files/README.md b/net/ngvlan/files/README.md >new file mode 100644 >index 000000000..54312bada >--- /dev/null >+++ b/net/ngvlan/files/README.md >@@ -0,0 +1,61 @@ >+# ngvlan >+ >+`ngvlan` is FreeBSD rc.d script that sets up/tears down VLAN interfaces using >+Netgraph. Unlike the traditional `vlan(4)`, `ngvlan` allows forwarding >+untagged VLAN (often the management VLAN) traffic to a `bridge(4)` interface. >+ >+# Quickstart >+ >+The following `/etc/rc.conf` snippet creates `genet0.256` through `genet0.259` >+ >+```sh >+# Configure tagged VLANs 256-259 on genet0. >+# This creates VLAN interfaces genet0.256 through genet0.259. >+ngvlan_enable="YES" >+ngvlan_interfaces="genet0" >+ngvlan_genet0_vlans="256 257 258 259" >+``` >+ >+# Per-VLAN bridges for jails and/or bhyves >+ >+The following `/etc/rc.conf` snippet configures per-VLAN bridges >+for untagged management VLAN 1 and tagged VLANs 256-259. >+VLAN traffic is diverted to and merged from per-VLAN bridges, via: >+* VLAN interfaces created by `ngvlan` (for tagged VLANs); >+* the parent interface (for the untagged management VLAN). >+ >+```sh >+# Configure tagged VLANs 256-259 on genet0. >+# This creates VLAN interfaces genet0.256 through genet0.259. >+ngvlan_enable="YES" >+ngvlan_interfaces="genet0" >+ngvlan_genet0_vlans="256 257 258 259" >+ >+# Add the parent interface (for the untagged management VLAN 1) and >+# the VLAN interfaces (for tagged VLANs 256-259) to their per-VLAN bridges. >+cloned_interfaces="bridge1 bridge256 bridge257 bridge258 bridge259" >+autobridge_interfaces="bridge1 bridge256 bridge257 bridge258 bridge259" >+autobridge_bridge1="genet0" >+autobridge_bridge256="genet0.256" >+autobridge_bridge257="genet0.257" >+autobridge_bridge258="genet0.258" >+autobridge_bridge259="genet0.259" >+ >+# Configure bridge1 with management IP addresses and routing. >+# auto_linklocal ensures bridge1 gets a LL address (required for NDP to work). >+ifconfig_bridge1="inet 192.0.2.25/24" >+ifconfig_bridge1_ipv6="inet6 2001:db8:1234:5678::19/64 auto_linklocal" >+defaultrouter="192.0.2.1" >+ipv6_defaultrouter="2001:db8:1234:5678::1" >+ >+# Ensure the other interfaces are up even though they do not get IP addresses. >+ifconfig_genet0="up" # parent >+ifconfig_genet0_256="up" # tagged ngvlan interfaces >+ifconfig_genet0_257="up" >+ifconfig_genet0_258="up" >+ifconfig_genet0_259="up" >+ifconfig_bridge256="up" # per-VLAN bridges >+ifconfig_bridge257="up" >+ifconfig_bridge258="up" >+ifconfig_bridge259="up" >+``` >diff --git a/net/ngvlan/files/ngvlan.in b/net/ngvlan/files/ngvlan.in >new file mode 100755 >index 000000000..72a11712b >--- /dev/null >+++ b/net/ngvlan/files/ngvlan.in >@@ -0,0 +1,118 @@ >+#!/bin/sh >+ >+# PROVIDE: ngvlan >+# REQUIRE: FILESYSTEMS iovctl serial sppp sysctl >+# BEFORE: netif >+# KEYWORD: nojail >+# >+# Add these lines to /etc/rc.conf.local or /etc/rc.conf >+# to enable this service: >+# >+# ngvlan_enable (bool): Set to NO by default. >+# Set it to YES to enable ngvlan. >+# ngvlan_interfaces (str): Set to space-separated parent interfaces. >+# ngvlan_IF_vlans (integers): Set to space-separated tagged VLAN IDs >+# for the given parent IF. >+ >+. /etc/rc.subr >+. /etc/network.subr >+ >+name="ngvlan" >+desc="Netgraph VLAN interface setup" >+rcvar="${name}_enable" >+start_cmd="ngvlan_start" >+stop_cmd="ngvlan_stop" >+cmdifn= >+ >+ngvlan_create() >+{ >+ local iface sep vlans vlan ngeth drop_bad upper_peer >+ iface="${1}" >+ shift >+ echo -n "Setting up ng_vlan on ${iface}" >+ sep=": " >+ ngctl mkpeer "${iface}:" vlan lower downstream >+ ngctl name "${iface}:lower" "${iface}-vlan" >+ vlans=$(get_if_var "${iface}" ngvlan_IF_vlans) >+ for vlan in ${vlans} >+ do >+ echo -n "${sep}${vlan}" >+ sep=" " >+ ngctl mkpeer "${iface}-vlan:" eiface "${vlan}" ether >+ ngctl name "${iface}-vlan:${vlan}" "${iface}-vlan${vlan}" >+ ngctl msg "${iface}-vlan:" addfilter "{ vlan=${vlan} hook=\"${vlan}\" }" >+ if ngeth=$( >+ ngctl msg "${iface}-vlan${vlan}:" getifname | >+ sed -n 's/^args:[[:space:]]*"\([^"]*\)"[[:space:]]*$/\1/pi' | >+ grep . >+ ) >+ then >+ ifconfig "${ngeth}" name "${iface}.${vlan}" > /dev/null >+ fi >+ done >+ upper_peer="${iface}-vlan:nomatch" >+ case $(get_if_var "${iface}" ngvlan_IF_drop_bad) in >+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) >+ warn "bad VLAN drop is not supported yet" >+ ;; >+ esac >+ ngctl connect "${upper_peer%:*}:" "${iface}:" "${upper_peer##*:}" upper >+ echo "." >+} >+ >+ngvlan_destroy() >+{ >+ local iface sep vlans vlan >+ iface="${1}" >+ shift >+ echo -n "Tearing down ng_vlan on ${iface}" >+ sep=": " >+ case $(get_if_var "${iface}" ngvlan_IF_drop_bad) in >+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) >+ warn "bad VLAN drop is not supported yet" >+ ;; >+ esac >+ vlans=$(get_if_var "${iface}" ngvlan_IF_vlans) >+ for vlan in ${vlans} >+ do >+ echo -n "${sep}${vlan}" >+ sep=" " >+ ngctl shutdown "${iface}-vlan${vlan}:" >+ done >+ ngctl shutdown "${iface}-vlan:" >+ echo "." >+} >+ >+ngvlan_start() >+{ >+ case $# in >+ 0) >+ set -- ${ngvlan_interfaces} >+ ;; >+ esac >+ local iface >+ for iface >+ do >+ ngvlan_create "${iface}" >+ done >+} >+ >+ngvlan_stop() >+{ >+ case $# in >+ 0) >+ set -- ${ngvlan_interfaces} >+ ;; >+ esac >+ local iface >+ for iface >+ do >+ ngvlan_destroy "${iface}" >+ done >+} >+ >+# Load the old "network" config file also for compatibility. >+# This is needed for mfsBSD at least. >+load_rc_config network >+load_rc_config $name >+run_rc_command $* >diff --git a/net/ngvlan/pkg-descr b/net/ngvlan/pkg-descr >new file mode 100644 >index 000000000..05797d506 >--- /dev/null >+++ b/net/ngvlan/pkg-descr >@@ -0,0 +1,3 @@ >+`ngvlan` is FreeBSD rc.d script that sets up/tears down VLAN interfaces using >+Netgraph. Unlike the traditional `vlan(4)`, `ngvlan` allows forwarding >+untagged VLAN (often the management VLAN) traffic to a `bridge(4)` interface. >-- >2.45.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 286755
: 260362