Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167834886
D58643.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D58643.diff
View Options
diff --git a/sys/net/if.c b/sys/net/if.c
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1468,6 +1468,26 @@
IFNET_WUNLOCK();
}
+int
+if_foreach_group(struct ifnet *ifp, if_foreach_group_cb_t cb, void *cb_arg)
+{
+ struct ifg_list *ifgl;
+ int error;
+
+ MPASS(cb);
+
+ error = 0;
+ IFNET_RLOCK();
+ CK_STAILQ_FOREACH(ifgl, &ifp->if_groups, ifgl_next) {
+ error = cb(ifgl->ifgl_group, cb_arg);
+ if (error != 0)
+ break;
+ }
+ IFNET_RUNLOCK();
+
+ return (error);
+}
+
/*
* Stores all groups from an interface in memory pointed to by ifgr.
*/
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -525,6 +525,8 @@
#define MCDPRINTF(...)
#endif
+typedef int (*if_foreach_group_cb_t)(struct ifg_group *, void *);
+int if_foreach_group(if_t, if_foreach_group_cb_t, void *);
int if_addgroup(if_t, const char *);
int if_delgroup(if_t, const char *);
int if_addmulti(if_t, struct sockaddr *, struct ifmultiaddr **);
diff --git a/sys/netlink/netlink_snl_route_parsers.h b/sys/netlink/netlink_snl_route_parsers.h
--- a/sys/netlink/netlink_snl_route_parsers.h
+++ b/sys/netlink/netlink_snl_route_parsers.h
@@ -174,6 +174,11 @@
sizeof(struct snl_parsed_route), _fp_p_route, _nla_p_route,
_cb_p_route);
+static const struct snl_attr_parser _nla_p_ifgroups[] = {
+ { .type = IFLAF_GROUP, .cb = snl_attr_copy_string, .arg_u32 = sizeof(char[IFNAMSIZ]) },
+};
+SNL_DECLARE_ATTR_PARSER_EXT(_ifgroups_parser, sizeof(char[IFNAMSIZ]), _nla_p_ifgroups, NULL);
+
/* RTM_<NEW|DEL|GET>LINK message parser */
struct snl_parsed_link {
uint32_t ifi_index;
@@ -191,6 +196,7 @@
struct rtnl_link_stats64 *ifla_stats64;
struct nlattr *iflaf_orig_hwaddr;
struct snl_attr_bitset iflaf_caps;
+ struct snl_parray iflaf_groups;
};
#define _IN(_field) offsetof(struct ifinfomsg, _field)
@@ -198,6 +204,8 @@
static const struct snl_attr_parser _nla_p_link_fbsd[] = {
{ .type = IFLAF_ORIG_HWADDR, .off = _OUT(iflaf_orig_hwaddr), .cb = snl_attr_dup_nla },
{ .type = IFLAF_CAPS, .off = _OUT(iflaf_caps), .cb = snl_attr_get_bitset_c },
+ { .type = IFLAF_GROUP, .off = _OUT(iflaf_groups), .cb = snl_attr_get_parray,
+ .arg = &_ifgroups_parser },
};
SNL_DECLARE_ATTR_PARSER(_link_fbsd_parser, _nla_p_link_fbsd);
diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c
--- a/sys/netlink/route/iface.c
+++ b/sys/netlink/route/iface.c
@@ -204,6 +204,38 @@
}
}
+static int
+dump_group_cb(struct ifg_group *ifg, void *_arg)
+{
+ struct nl_writer *nw = (struct nl_writer *)_arg;
+ int off, ret = 0;
+
+ off = nlattr_add_nested(nw, IFLAF_GROUP);
+ if (off == 0)
+ return (ENOMEM);
+
+ if (!nlattr_add_string(nw, IFLAF_GROUP, ifg->ifg_group))
+ ret = ENOMEM;
+
+ nlattr_set_len(nw, off);
+ return (ret);
+}
+
+static int
+dump_group(struct nl_writer *nw, if_t ifp)
+{
+ int off, ret;
+
+ off = nlattr_add_nested(nw, IFLAF_GROUP);
+ if (off == 0)
+ return (ENOMEM);
+
+ ret = if_foreach_group(ifp, dump_group_cb, nw);
+ nlattr_set_len(nw, off);
+
+ return (ret);
+}
+
static unsigned
ifp_flags_to_netlink(const if_t ifp)
{
@@ -344,7 +376,6 @@
/*
nlattr_add_u32(nw, IFLA_MIN_MTU, 60);
nlattr_add_u32(nw, IFLA_MAX_MTU, 9000);
- nlattr_add_u32(nw, IFLA_GROUP, 0);
*/
if (if_getdescr(ifp) != NULL)
@@ -355,6 +386,8 @@
if (off != 0) {
get_hwaddr(nw, ifp);
dump_iface_caps(nw, ifp);
+ if (dump_group(nw, ifp) != 0)
+ goto enomem;
nlattr_set_len(nw, off);
}
diff --git a/sys/netlink/route/interface.h b/sys/netlink/route/interface.h
--- a/sys/netlink/route/interface.h
+++ b/sys/netlink/route/interface.h
@@ -152,6 +152,7 @@
IFLAF_ORIG_IFNAME = 1, /* string, original interface name at creation */
IFLAF_ORIG_HWADDR = 2, /* binary, original hardware address */
IFLAF_CAPS = 3, /* bitset, interface capabilities */
+ IFLAF_GROUP = 4, /* string, interface group name (multi-attr) */
__IFLAF_MAX
};
#define IFLAF_MAX (__IFLAF_MAX - 1)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 25, 9:17 PM (15 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37251929
Default Alt Text
D58643.diff (3 KB)
Attached To
Mode
D58643: rtnetlink: Add FreeBSD-specific IFLAF_GROUP support
Attached
Detach File
Event Timeline
Log In to Comment