[systemd-commits] 4 commits - src/libsystemd src/systemd
Tom Gundersen
tomegun at kemper.freedesktop.org
Wed Oct 29 03:18:22 PDT 2014
src/libsystemd/sd-rtnl/rtnl-message.c | 20 ++++++++++++++++++--
src/libsystemd/sd-rtnl/rtnl-types.c | 19 ++++++++++++++++++-
src/systemd/sd-rtnl.h | 1 +
3 files changed, 37 insertions(+), 3 deletions(-)
New commits:
commit d0159fdc7a1009027f019f763106aa13256cf030
Author: Susant Sahani <susant at redhat.com>
Date: Mon Jul 21 13:32:09 2014 +0530
sd-rtnl: add bridge port rtnl attributes.
Add bridge port attributes to sd-rtnl to configure
via networkd.
diff --git a/src/libsystemd/sd-rtnl/rtnl-types.c b/src/libsystemd/sd-rtnl/rtnl-types.c
index df9a45d..b6c483c 100644
--- a/src/libsystemd/sd-rtnl/rtnl-types.c
+++ b/src/libsystemd/sd-rtnl/rtnl-types.c
@@ -211,7 +211,23 @@ static const NLTypeSystem rtnl_link_info_type_system = {
.types = rtnl_link_info_types,
};
-static const NLType rtnl_link_types[IFLA_MAX + 1] = {
+static const struct NLType rtnl_bridge_port_types[IFLA_BRPORT_MAX + 1] = {
+ [IFLA_BRPORT_STATE] = { .type = NLA_U8 },
+ [IFLA_BRPORT_COST] = { .type = NLA_U32 },
+ [IFLA_BRPORT_PRIORITY] = { .type = NLA_U16 },
+ [IFLA_BRPORT_MODE] = { .type = NLA_U8 },
+ [IFLA_BRPORT_GUARD] = { .type = NLA_U8 },
+ [IFLA_BRPORT_PROTECT] = { .type = NLA_U8 },
+ [IFLA_BRPORT_LEARNING] = { .type = NLA_U8 },
+ [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NLA_U8 },
+};
+
+static const NLTypeSystem rtnl_bridge_port_type_system = {
+ .max = ELEMENTSOF(rtnl_bridge_port_types) - 1,
+ .types = rtnl_bridge_port_types,
+};
+
+static const NLType rtnl_link_types[IFLA_MAX + 1 ] = {
[IFLA_ADDRESS] = { .type = NLA_ETHER_ADDR, },
[IFLA_BROADCAST] = { .type = NLA_ETHER_ADDR, },
[IFLA_IFNAME] = { .type = NLA_STRING, .size = IFNAMSIZ - 1, },
@@ -228,6 +244,7 @@ static const NLType rtnl_link_types[IFLA_MAX + 1] = {
[IFLA_WIRELESS],
[IFLA_PROTINFO],
*/
+ [IFLA_PROTINFO] = { .type = NLA_NESTED, .type_system = &rtnl_bridge_port_type_system },
[IFLA_TXQLEN] = { .type = NLA_U32 },
/*
[IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
commit 64c8407133fdc1887785789d0fe574bc21035433
Author: Susant Sahani <susant at redhat.com>
Date: Mon Jul 21 13:15:38 2014 +0530
sd-rtnl: add support to set packet family type
This patch adds functionality to set family type
in the rtnl message for example PF_BRIDGE.
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index ccef716..44ad303 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -186,6 +186,20 @@ int sd_rtnl_message_link_set_type(sd_rtnl_message *m, unsigned type) {
return 0;
}
+int sd_rtnl_message_link_set_family(sd_rtnl_message *m, unsigned family) {
+ struct ifinfomsg *ifi;
+
+ assert_return(m, -EINVAL);
+ assert_return(m->hdr, -EINVAL);
+ assert_return(rtnl_message_type_is_link(m->hdr->nlmsg_type), -EINVAL);
+
+ ifi = NLMSG_DATA(m->hdr);
+
+ ifi->ifi_family = family;
+
+ return 0;
+}
+
int sd_rtnl_message_new_link(sd_rtnl *rtnl, sd_rtnl_message **ret,
uint16_t nlmsg_type, int index) {
struct ifinfomsg *ifi;
diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h
index 1e7eb81..0980de8 100644
--- a/src/systemd/sd-rtnl.h
+++ b/src/systemd/sd-rtnl.h
@@ -93,6 +93,7 @@ int sd_rtnl_message_addr_get_ifindex(sd_rtnl_message *m, int *ifindex);
int sd_rtnl_message_link_set_flags(sd_rtnl_message *m, unsigned flags, unsigned change);
int sd_rtnl_message_link_set_type(sd_rtnl_message *m, unsigned type);
+int sd_rtnl_message_link_set_family(sd_rtnl_message *m, unsigned family);
int sd_rtnl_message_link_get_ifindex(sd_rtnl_message *m, int *ifindex);
int sd_rtnl_message_link_get_flags(sd_rtnl_message *m, unsigned *flags);
int sd_rtnl_message_link_get_type(sd_rtnl_message *m, unsigned *type);
commit fcf81a54a4a01349cbc75a9f04d49c6084c4f624
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Oct 29 10:52:07 2014 +0100
sd-rtnl: mark nested attributes with the NLA_F_NESTED flag
The kernel mostly does not check this, but let's be consisntent and allways set it anyway. Based
on patch from Susant Sahani.
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index dac3061..ccef716 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -725,7 +725,7 @@ int sd_rtnl_message_open_container(sd_rtnl_message *m, unsigned short type) {
if (r < 0)
return r;
- r = add_rtattr(m, type, NULL, size);
+ r = add_rtattr(m, type | NLA_F_NESTED, NULL, size);
if (r < 0)
return r;
commit 0a2478a918763f73de5d1b78ebb1023c31042583
Author: Tom Gundersen <teg at jklm.no>
Date: Wed Oct 29 10:50:33 2014 +0100
sd-rtnl: fix reading of nla type
We must filter out the 'network-byteorder' and 'nested' flags.
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index b501a52..dac3061 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -36,6 +36,8 @@
#define GET_CONTAINER(m, i) ((i) < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->container_offsets[i]) : NULL)
#define PUSH_CONTAINER(m, new) (m)->container_offsets[(m)->n_containers ++] = (uint8_t*)(new) - (uint8_t*)(m)->hdr;
+#define RTA_TYPE(rta) ((rta)->rta_type & NLA_TYPE_MASK)
+
static int message_new_empty(sd_rtnl *rtnl, sd_rtnl_message **ret) {
sd_rtnl_message *m;
@@ -1066,7 +1068,7 @@ int rtnl_message_parse(sd_rtnl_message *m,
*rta_tb_size = max + 1;
for (; RTA_OK(rta, rt_len); rta = RTA_NEXT(rta, rt_len)) {
- type = rta->rta_type;
+ type = RTA_TYPE(rta);
/* if the kernel is newer than the headers we used
when building, we ignore out-of-range attributes
More information about the systemd-commits
mailing list