Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144341053
D38715.id117778.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D38715.id117778.diff
View Options
diff --git a/sys/compat/linux/linux_netlink.c b/sys/compat/linux/linux_netlink.c
--- a/sys/compat/linux/linux_netlink.c
+++ b/sys/compat/linux/linux_netlink.c
@@ -224,10 +224,52 @@
return (false);
}
+/*
+ * Translate a FreeBSD interface name to a Linux interface name.
+ */
+static bool
+nlmsg_translate_ifname_nla(struct nlattr *nla, struct nl_writer *nw)
+{
+ char ifname[LINUX_IFNAMSIZ];
+
+ if (ifname_bsd_to_linux_name((char *)(nla + 1), ifname,
+ sizeof(ifname)) <= 0)
+ return (false);
+ return (nlattr_add_string(nw, IFLA_IFNAME, ifname));
+}
+
+#define LINUX_NLA_UNHANDLED -1
+/*
+ * Translate a FreeBSD attribute to a Linux attribute.
+ * Returns LINUX_NLA_UNHANDLED when the attribute is not processed
+ * and the caller must take care of it, otherwise the result is returned.
+ */
+static int
+nlmsg_translate_all_nla(struct nlmsghdr *hdr, struct nlattr *nla,
+ struct nl_writer *nw)
+{
+
+ switch (hdr->nlmsg_type) {
+ case NL_RTM_NEWLINK:
+ case NL_RTM_DELLINK:
+ case NL_RTM_GETLINK:
+ switch (nla->nla_type) {
+ case IFLA_IFNAME:
+ return (nlmsg_translate_ifname_nla(nla, nw));
+ default:
+ break;
+ }
+ default:
+ break;
+ }
+ return (LINUX_NLA_UNHANDLED);
+}
+
static bool
nlmsg_copy_all_nla(struct nlmsghdr *hdr, int raw_hdrlen, struct nl_writer *nw)
{
struct nlattr *nla;
+ int ret;
int hdrlen = NETLINK_ALIGN(raw_hdrlen);
int attrs_len = hdr->nlmsg_len - sizeof(struct nlmsghdr) - hdrlen;
@@ -238,11 +280,15 @@
if (nla->nla_len < sizeof(struct nlattr)) {
return (false);
}
- if (!nlmsg_copy_nla(nla, nw))
+ ret = nlmsg_translate_all_nla(hdr, nla, nw);
+ if (ret == LINUX_NLA_UNHANDLED)
+ ret = nlmsg_copy_nla(nla, nw);
+ if (!ret)
return (false);
}
return (true);
}
+#undef LINUX_NLA_UNHANDLED
static unsigned int
rtnl_if_flags_to_linux(unsigned int if_flags)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 8, 10:44 PM (3 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28507015
Default Alt Text
D38715.id117778.diff (1 KB)
Attached To
Mode
D38715: linux(4): Fixup the interface name translation in netlink
Attached
Detach File
Event Timeline
Log In to Comment