Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F157834954
D38790.id117954.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D38790.id117954.diff
View Options
diff --git a/sys/compat/linsysfs/linsysfs.c b/sys/compat/linsysfs/linsysfs.c
--- a/sys/compat/linsysfs/linsysfs.c
+++ b/sys/compat/linsysfs/linsysfs.c
@@ -72,14 +72,17 @@
static int
linsysfs_ifnet_addr(PFS_FILL_ARGS)
{
+ struct epoch_tracker et;
struct l_sockaddr lsa;
struct ifnet *ifp;
- ifp = ifname_linux_to_bsd(td, pn->pn_parent->pn_name, NULL);
- if (ifp == NULL)
- return (ENOENT);
- if (linux_ifhwaddr(ifp, &lsa) != 0)
+ NET_EPOCH_ENTER(et);
+ ifp = ifname_linux_to_ifp(td, pn->pn_parent->pn_name);
+ if (ifp == NULL || linux_ifhwaddr(ifp, &lsa) != 0) {
+ NET_EPOCH_EXIT(et);
return (ENOENT);
+ }
+ NET_EPOCH_EXIT(et);
sbuf_printf(sb, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
lsa.sa_data[0], lsa.sa_data[1], lsa.sa_data[2],
lsa.sa_data[3], lsa.sa_data[4], lsa.sa_data[5]);
@@ -97,13 +100,18 @@
static int
linsysfs_ifnet_flags(PFS_FILL_ARGS)
{
+ struct epoch_tracker et;
struct ifnet *ifp;
unsigned short flags;
- ifp = ifname_linux_to_bsd(td, pn->pn_parent->pn_name, NULL);
- if (ifp == NULL)
+ NET_EPOCH_ENTER(et);
+ ifp = ifname_linux_to_ifp(td, pn->pn_parent->pn_name);
+ if (ifp == NULL) {
+ NET_EPOCH_EXIT(et);
return (ENOENT);
+ }
linux_ifflags(ifp, &flags);
+ NET_EPOCH_EXIT(et);
sbuf_printf(sb, "0x%x\n", flags);
return (0);
}
@@ -111,24 +119,38 @@
static int
linsysfs_ifnet_ifindex(PFS_FILL_ARGS)
{
+ struct epoch_tracker et;
struct ifnet *ifp;
+ short if_index;
- ifp = ifname_linux_to_bsd(td, pn->pn_parent->pn_name, NULL);
- if (ifp == NULL)
+ NET_EPOCH_ENTER(et);
+ ifp = ifname_linux_to_ifp(td, pn->pn_parent->pn_name);
+ if (ifp == NULL) {
+ NET_EPOCH_EXIT(et);
return (ENOENT);
- sbuf_printf(sb, "%u\n", if_getindex(ifp));
+ }
+ if_index = if_getindex(ifp);
+ NET_EPOCH_EXIT(et);
+ sbuf_printf(sb, "%u\n", if_index);
return (0);
}
static int
linsysfs_ifnet_mtu(PFS_FILL_ARGS)
{
+ struct epoch_tracker et;
struct ifnet *ifp;
+ int if_mtu;
- ifp = ifname_linux_to_bsd(td, pn->pn_parent->pn_name, NULL);
- if (ifp == NULL)
+ NET_EPOCH_ENTER(et);
+ ifp = ifname_linux_to_ifp(td, pn->pn_parent->pn_name);
+ if (ifp == NULL) {
+ NET_EPOCH_EXIT(et);
return (ENOENT);
- sbuf_printf(sb, "%u\n", if_getmtu(ifp));
+ }
+ if_mtu = if_getmtu(ifp);
+ NET_EPOCH_EXIT(et);
+ sbuf_printf(sb, "%u\n", if_mtu);
return (0);
}
@@ -144,14 +166,17 @@
static int
linsysfs_ifnet_type(PFS_FILL_ARGS)
{
+ struct epoch_tracker et;
struct l_sockaddr lsa;
struct ifnet *ifp;
- ifp = ifname_linux_to_bsd(td, pn->pn_parent->pn_name, NULL);
- if (ifp == NULL)
- return (ENOENT);
- if (linux_ifhwaddr(ifp, &lsa) != 0)
+ NET_EPOCH_ENTER(et);
+ ifp = ifname_linux_to_ifp(td, pn->pn_parent->pn_name);
+ if (ifp == NULL || linux_ifhwaddr(ifp, &lsa) != 0) {
+ NET_EPOCH_EXIT(et);
return (ENOENT);
+ }
+ NET_EPOCH_EXIT(et);
sbuf_printf(sb, "%d\n", lsa.sa_family);
return (0);
}
diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c
--- a/sys/compat/linux/linux.c
+++ b/sys/compat/linux/linux.c
@@ -379,17 +379,18 @@
}
struct ifnet *
-ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname)
+ifname_linux_to_ifp(struct thread *td, const char *lxname)
{
struct ifname_linux_to_bsd_cb_s arg = {
.ethno = 0,
.lxname = lxname,
.ifp = NULL,
};
- struct epoch_tracker et;
- int len, ret;
+ int len;
char *ep;
+ NET_EPOCH_ASSERT();
+
for (len = 0; len < LINUX_IFNAMSIZ; ++len)
if (!isalpha(lxname[len]) || lxname[len] == '\0')
break;
@@ -406,14 +407,24 @@
return (NULL);
arg.is_eth = (len == 3 && strncmp(lxname, "eth", len) == 0);
+ if_foreach(ifname_linux_to_bsd_cb, &arg);
+ return (arg.ifp);
+}
+
+struct ifnet *
+ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname)
+{
+ struct epoch_tracker et;
+ struct ifnet *ifp;
+
CURVNET_SET(TD_TO_VNET(td));
NET_EPOCH_ENTER(et);
- ret = if_foreach(ifname_linux_to_bsd_cb, &arg);
+ ifp = ifname_linux_to_ifp(td, lxname);
+ if (ifp != NULL && bsdname != NULL)
+ strlcpy(bsdname, if_name(ifp), IFNAMSIZ);
NET_EPOCH_EXIT(et);
CURVNET_RESTORE();
- if (ret > 0 && arg.ifp != NULL && bsdname != NULL)
- strlcpy(bsdname, if_name(arg.ifp), IFNAMSIZ);
- return (arg.ifp);
+ return (ifp);
}
void
diff --git a/sys/compat/linux/linux_common.h b/sys/compat/linux/linux_common.h
--- a/sys/compat/linux/linux_common.h
+++ b/sys/compat/linux/linux_common.h
@@ -33,6 +33,7 @@
int ifname_bsd_to_linux_ifp(struct ifnet *, char *, size_t);
int ifname_bsd_to_linux_idx(u_int, char *, size_t);
int ifname_bsd_to_linux_name(const char *, char *, size_t);
+struct ifnet *ifname_linux_to_ifp(struct thread *, const char *);
struct ifnet *ifname_linux_to_bsd(struct thread *td,
const char *lxname, char *bsdname);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 26, 5:39 PM (3 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33534194
Default Alt Text
D38790.id117954.diff (4 KB)
Attached To
Mode
D38790: linsysfs(4): Refactor to avoid referencing an unstable interfaces
Attached
Detach File
Event Timeline
Log In to Comment