summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/net/if_stf.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-04-04 09:36:57 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-04-04 14:46:23 +0200
commitde8a76da2f374792594ce03a203b3f30e4889f6f (patch)
tree12b5e1e59358005c3c522955c08aee4795e4829c /freebsd/sys/net/if_stf.c
parentEnable bridging by default (diff)
downloadrtems-libbsd-de8a76da2f374792594ce03a203b3f30e4889f6f.tar.bz2
Update to FreeBSD head 2017-04-04
Git mirror commit 642b174daddbd0efd9bb5f242c43f4ab4db6869f.
Diffstat (limited to 'freebsd/sys/net/if_stf.c')
-rw-r--r--freebsd/sys/net/if_stf.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/freebsd/sys/net/if_stf.c b/freebsd/sys/net/if_stf.c
index 7c1b7075..e07cf0fe 100644
--- a/freebsd/sys/net/if_stf.c
+++ b/freebsd/sys/net/if_stf.c
@@ -204,10 +204,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
@@ -235,7 +241,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;
@@ -327,8 +346,7 @@ stf_encapcheck(const struct mbuf *m, int off, int proto, void *arg)
if (proto != IPPROTO_IPV6)
return 0;
- /* LINTED const cast */
- m_copydata((struct mbuf *)(uintptr_t)m, 0, sizeof(ip), (caddr_t)&ip);
+ m_copydata(m, 0, sizeof(ip), (caddr_t)&ip);
if (ip.ip_v != 4)
return 0;