mirror of
https://github.com/systemd/systemd.git
synced 2025-02-04 21:47:31 +03:00
sd-netlink: hook up nsid APIs
This commit is contained in:
parent
414ae39821
commit
1078628096
@ -56,6 +56,10 @@ static bool rtnl_message_type_is_mdb(uint16_t type) {
|
||||
return IN_SET(type, RTM_NEWMDB, RTM_DELMDB, RTM_GETMDB);
|
||||
}
|
||||
|
||||
static bool rtnl_message_type_is_nsid(uint16_t type) {
|
||||
return IN_SET(type, RTM_NEWNSID, RTM_DELNSID, RTM_GETNSID);
|
||||
}
|
||||
|
||||
int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen) {
|
||||
struct rtmsg *rtm;
|
||||
|
||||
@ -1216,3 +1220,24 @@ int sd_rtnl_message_new_mdb(
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sd_rtnl_message_new_nsid(
|
||||
sd_netlink *rtnl,
|
||||
sd_netlink_message **ret,
|
||||
uint16_t nlmsg_type) {
|
||||
|
||||
struct rtgenmsg *rt;
|
||||
int r;
|
||||
|
||||
assert_return(rtnl_message_type_is_nsid(nlmsg_type), -EINVAL);
|
||||
assert_return(ret, -EINVAL);
|
||||
|
||||
r = message_new(rtnl, ret, nlmsg_type);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
rt = NLMSG_DATA((*ret)->hdr);
|
||||
rt->rtgen_family = AF_UNSPEC;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <linux/if_tunnel.h>
|
||||
#include <linux/ip.h>
|
||||
#include <linux/l2tp.h>
|
||||
#include <linux/net_namespace.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/nexthop.h>
|
||||
#include <linux/nl80211.h>
|
||||
@ -1185,6 +1186,13 @@ static const NLAPolicy rtnl_mdb_policies[] = {
|
||||
|
||||
DEFINE_POLICY_SET(rtnl_mdb);
|
||||
|
||||
static const NLAPolicy rtnl_nsid_policies[] = {
|
||||
[NETNSA_FD] = BUILD_POLICY(S32),
|
||||
[NETNSA_NSID] = BUILD_POLICY(U32),
|
||||
};
|
||||
|
||||
DEFINE_POLICY_SET(rtnl_nsid);
|
||||
|
||||
static const NLAPolicy rtnl_policies[] = {
|
||||
[RTM_NEWLINK] = BUILD_POLICY_NESTED_WITH_SIZE(rtnl_link, sizeof(struct ifinfomsg)),
|
||||
[RTM_DELLINK] = BUILD_POLICY_NESTED_WITH_SIZE(rtnl_link, sizeof(struct ifinfomsg)),
|
||||
@ -1220,6 +1228,9 @@ static const NLAPolicy rtnl_policies[] = {
|
||||
[RTM_NEWMDB] = BUILD_POLICY_NESTED_WITH_SIZE(rtnl_mdb, sizeof(struct br_port_msg)),
|
||||
[RTM_DELMDB] = BUILD_POLICY_NESTED_WITH_SIZE(rtnl_mdb, sizeof(struct br_port_msg)),
|
||||
[RTM_GETMDB] = BUILD_POLICY_NESTED_WITH_SIZE(rtnl_mdb, sizeof(struct br_port_msg)),
|
||||
[RTM_NEWNSID] = BUILD_POLICY_NESTED_WITH_SIZE(rtnl_nsid, sizeof(struct rtgenmsg)),
|
||||
[RTM_DELNSID] = BUILD_POLICY_NESTED_WITH_SIZE(rtnl_nsid, sizeof(struct rtgenmsg)),
|
||||
[RTM_GETNSID] = BUILD_POLICY_NESTED_WITH_SIZE(rtnl_nsid, sizeof(struct rtgenmsg)),
|
||||
};
|
||||
|
||||
DEFINE_POLICY_SET(rtnl);
|
||||
|
@ -216,6 +216,8 @@ int sd_rtnl_message_traffic_control_get_parent(sd_netlink_message *m, uint32_t *
|
||||
|
||||
int sd_rtnl_message_new_mdb(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type, int mdb_ifindex);
|
||||
|
||||
int sd_rtnl_message_new_nsid(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t nlmsg_type);
|
||||
|
||||
/* genl */
|
||||
int sd_genl_socket_open(sd_netlink **ret);
|
||||
int sd_genl_message_new(sd_netlink *genl, const char *family_name, uint8_t cmd, sd_netlink_message **ret);
|
||||
|
Loading…
x
Reference in New Issue
Block a user