summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Otavio O Souza <luiz@netgate.com>2017-01-28 20:08:09 -0600
committerLuiz Souza <luiz@netgate.com>2017-07-17 19:29:12 -0500
commitad33aae9e768d5cc109d5830881677d5f62134d8 (patch)
treee56f413e41a7d8d45b67aa8ca570552cd7dbfac9
parent96f4336dc137d807fa8839df573a34ed6a130772 (diff)
downloadFreeBSD-src-ad33aae9e768d5cc109d5830881677d5f62134d8.zip
FreeBSD-src-ad33aae9e768d5cc109d5830881677d5f62134d8.tar.gz
Update the interface name before return and fix the kernel panic when pf is loaded and the stf interface is created without the unit number:
Ticket #7124 (cherry picked from commit c050d42a2646d2e582c46cc6f61531150ffb6cb9)
-rw-r--r--sys/net/if_stf.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index 5209bc8..d11ec54 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -202,10 +202,16 @@ stf_clone_match(struct if_clone *ifc, const char *name)
static int
stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
{
- int err, unit;
+ char *dp;
+ int err, unit, wildcard;
struct stf_softc *sc;
struct ifnet *ifp;
+ err = ifc_name2unit(name, &unit);
+ if (err != 0)
+ return (err);
+ wildcard = (unit < 0);
+
/*
* We can only have one unit, but since unit allocation is
* already locked, we use it to keep from allocating extra
@@ -229,7 +235,20 @@ stf_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params)
/*
* Set the name manually rather then using if_initname because
* we don't conform to the default naming convention for interfaces.
+ * In the wildcard case, we need to update the name.
*/
+ if (wildcard) {
+ for (dp = name; *dp != '\0'; dp++);
+ if (snprintf(dp, len - (dp-name), "%d", unit) >
+ len - (dp-name) - 1) {
+ /*
+ * This can only be a programmer error and
+ * there's no straightforward way to recover if
+ * it happens.
+ */
+ panic("if_clone_create(): interface name too long");
+ }
+ }
strlcpy(ifp->if_xname, name, IFNAMSIZ);
ifp->if_dname = stfname;
ifp->if_dunit = IF_DUNIT_NONE;
OpenPOWER on IntegriCloud