summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-rtnl
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd/sd-rtnl')
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c15
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-util.c4
-rw-r--r--src/libsystemd/sd-rtnl/sd-rtnl.c8
-rw-r--r--src/libsystemd/sd-rtnl/test-rtnl.c33
4 files changed, 29 insertions, 31 deletions
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 5d4dc71810..8c20b8e765 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -85,9 +85,8 @@ int sd_rtnl_message_route_set_dst_prefixlen(sd_rtnl_message *m, unsigned char pr
return 0;
}
-int sd_rtnl_message_new_route(sd_rtnl *rtnl, uint16_t nlmsg_type,
- unsigned char rtm_family,
- sd_rtnl_message **ret) {
+int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
+ uint16_t nlmsg_type, unsigned char rtm_family) {
struct rtmsg *rtm;
int r;
@@ -147,8 +146,8 @@ int sd_rtnl_message_link_set_type(sd_rtnl_message *m, unsigned type) {
return 0;
}
-int sd_rtnl_message_new_link(sd_rtnl *rtnl, uint16_t nlmsg_type, int index,
- sd_rtnl_message **ret) {
+int sd_rtnl_message_new_link(sd_rtnl *rtnl, sd_rtnl_message **ret,
+ uint16_t nlmsg_type, int index) {
struct ifinfomsg *ifi;
int r;
@@ -222,9 +221,9 @@ int sd_rtnl_message_addr_set_scope(sd_rtnl_message *m, unsigned char scope) {
return 0;
}
-int sd_rtnl_message_new_addr(sd_rtnl *rtnl, uint16_t nlmsg_type, int index,
- unsigned char family,
- sd_rtnl_message **ret) {
+int sd_rtnl_message_new_addr(sd_rtnl *rtnl, sd_rtnl_message **ret,
+ uint16_t nlmsg_type, int index,
+ unsigned char family) {
struct ifaddrmsg *ifa;
int r;
diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c
index ec1a92e01f..fc834e9554 100644
--- a/src/libsystemd/sd-rtnl/rtnl-util.c
+++ b/src/libsystemd/sd-rtnl/rtnl-util.c
@@ -34,7 +34,7 @@ int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) {
assert(ifindex > 0);
assert(name);
- r = sd_rtnl_message_new_link(rtnl, RTM_SETLINK, ifindex, &message);
+ r = sd_rtnl_message_new_link(rtnl, &message, RTM_SETLINK, ifindex);
if (r < 0)
return r;
@@ -61,7 +61,7 @@ int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const char *alias,
if (!alias && !mac && mtu == 0)
return 0;
- r = sd_rtnl_message_new_link(rtnl, RTM_SETLINK, ifindex, &message);
+ r = sd_rtnl_message_new_link(rtnl, &message, RTM_SETLINK, ifindex);
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c
index 05889656f9..1b9f583726 100644
--- a/src/libsystemd/sd-rtnl/sd-rtnl.c
+++ b/src/libsystemd/sd-rtnl/sd-rtnl.c
@@ -70,7 +70,7 @@ static bool rtnl_pid_changed(sd_rtnl *rtnl) {
return rtnl->original_pid != getpid();
}
-int sd_rtnl_open(uint32_t groups, sd_rtnl **ret) {
+int sd_rtnl_open(sd_rtnl **ret, uint32_t groups) {
_cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
socklen_t addrlen;
int r;
@@ -774,7 +774,7 @@ int sd_rtnl_attach_event(sd_rtnl *rtnl, sd_event *event, int priority) {
return r;
}
- r = sd_event_add_io(rtnl->event, rtnl->fd, 0, io_callback, rtnl, &rtnl->io_event_source);
+ r = sd_event_add_io(rtnl->event, &rtnl->io_event_source, rtnl->fd, 0, io_callback, rtnl);
if (r < 0)
goto fail;
@@ -786,7 +786,7 @@ int sd_rtnl_attach_event(sd_rtnl *rtnl, sd_event *event, int priority) {
if (r < 0)
goto fail;
- r = sd_event_add_monotonic(rtnl->event, 0, 0, time_callback, rtnl, &rtnl->time_event_source);
+ r = sd_event_add_monotonic(rtnl->event, &rtnl->time_event_source, 0, 0, time_callback, rtnl);
if (r < 0)
goto fail;
@@ -794,7 +794,7 @@ int sd_rtnl_attach_event(sd_rtnl *rtnl, sd_event *event, int priority) {
if (r < 0)
goto fail;
- r = sd_event_add_exit(rtnl->event, exit_callback, rtnl, &rtnl->exit_event_source);
+ r = sd_event_add_exit(rtnl->event, &rtnl->exit_event_source, exit_callback, rtnl);
if (r < 0)
goto fail;
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 5ab06d5bad..497cefd4f9 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -37,7 +37,7 @@ static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
void *data;
/* we'd really like to test NEWLINK, but let's not mess with the running kernel */
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &message) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &message, RTM_GETLINK, ifindex) >= 0);
assert(sd_rtnl_message_append_string(message, IFLA_IFNAME, name) >= 0);
assert(sd_rtnl_message_append_ether_addr(message, IFLA_ADDRESS, ether_aton(mac)) >= 0);
assert(sd_rtnl_message_append_u32(message, IFLA_MTU, mtu) >= 0);
@@ -57,7 +57,6 @@ static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
assert(mtu == *(unsigned int *) data);
}
-
static void test_link_get(sd_rtnl *rtnl, int ifindex) {
sd_rtnl_message *m;
sd_rtnl_message *r;
@@ -66,7 +65,7 @@ static void test_link_get(sd_rtnl *rtnl, int ifindex) {
void *data;
uint16_t type;
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
assert(m);
/* u8 test cases */
@@ -137,7 +136,7 @@ static void test_route(void) {
void *data;
int r;
- r = sd_rtnl_message_new_route(NULL, RTM_NEWROUTE, AF_INET, &req);
+ r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET);
if (r < 0) {
log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
return;
@@ -171,8 +170,8 @@ static void test_route(void) {
static void test_multiple(void) {
sd_rtnl *rtnl1, *rtnl2;
- assert(sd_rtnl_open(0, &rtnl1) >= 0);
- assert(sd_rtnl_open(0, &rtnl2) >= 0);
+ assert(sd_rtnl_open(&rtnl1, 0) >= 0);
+ assert(sd_rtnl_open(&rtnl2, 0) >= 0);
rtnl1 = sd_rtnl_unref(rtnl1);
rtnl2 = sd_rtnl_unref(rtnl2);
@@ -215,8 +214,8 @@ static void test_event_loop(int ifindex) {
ifname = strdup("lo2");
assert(ifname);
- assert(sd_rtnl_open(0, &rtnl) >= 0);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
assert(sd_rtnl_call_async(rtnl, m, &link_handler, ifname, 0, NULL) >= 0);
@@ -248,9 +247,9 @@ static void test_async(int ifindex) {
ifname = strdup("lo");
assert(ifname);
- assert(sd_rtnl_open(0, &rtnl) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
assert(sd_rtnl_call_async(rtnl, m, &link_handler, ifname, 0, &serial) >= 0);
@@ -263,10 +262,10 @@ static void test_pipe(int ifindex) {
_cleanup_rtnl_message_unref_ sd_rtnl_message *m1 = NULL, *m2 = NULL;
int counter = 0;
- assert(sd_rtnl_open(0, &rtnl) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m1) >= 0);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m2) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m1, RTM_GETLINK, ifindex) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m2, RTM_GETLINK, ifindex) >= 0);
counter ++;
assert(sd_rtnl_call_async(rtnl, m1, &pipe_handler, &counter, 0, NULL) >= 0);
@@ -285,7 +284,7 @@ static void test_container(void) {
uint16_t type;
void *data;
- assert(sd_rtnl_message_new_link(NULL, RTM_NEWLINK, 0, &m) >= 0);
+ assert(sd_rtnl_message_new_link(NULL, &m, RTM_NEWLINK, 0) >= 0);
assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0);
assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) == -ENOTSUP);
@@ -325,7 +324,7 @@ static void test_container(void) {
static void test_match(void) {
_cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
- assert(sd_rtnl_open(0, &rtnl) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
assert(sd_rtnl_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0);
assert(sd_rtnl_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0);
@@ -351,7 +350,7 @@ int main(void) {
test_container();
- assert(sd_rtnl_open(0, &rtnl) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
assert(rtnl);
if_loopback = (int) if_nametoindex("lo");
@@ -365,7 +364,7 @@ int main(void) {
test_link_configure(rtnl, if_loopback);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, if_loopback, &m) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, if_loopback) >= 0);
assert(m);
assert(sd_rtnl_message_get_type(m, &type) >= 0);