Skip to content

Commit

Permalink
Merge pull request systemd#30694 from yuwata/sd-netlink-move-macro-an…
Browse files Browse the repository at this point in the history
…d-introduce-tos-getter

sd-netlink: two cleanups
  • Loading branch information
YHNdnzj authored Jan 3, 2024
2 parents f6ce1ad + ef4e0b7 commit 7c2e495
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/libsystemd/sd-netlink/netlink-message-rtnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char
return 0;
}

int sd_rtnl_message_route_set_tos(sd_netlink_message *m, unsigned char tos) {
struct rtmsg *rtm;

assert_return(m, -EINVAL);
assert_return(m->hdr, -EINVAL);
assert_return(rtnl_message_type_is_route(m->hdr->nlmsg_type), -EINVAL);

rtm = NLMSG_DATA(m->hdr);

rtm->rtm_tos = tos;

return 0;
}

int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope) {
struct rtmsg *rtm;

Expand Down
3 changes: 0 additions & 3 deletions src/libsystemd/sd-netlink/netlink-message.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#define GET_CONTAINER(m, i) ((struct rtattr*)((uint8_t*)(m)->hdr + (m)->containers[i].offset))

#define RTA_TYPE(rta) ((rta)->rta_type & NLA_TYPE_MASK)
#define RTA_FLAGS(rta) ((rta)->rta_type & ~NLA_TYPE_MASK)

int message_new_empty(sd_netlink *nl, sd_netlink_message **ret) {
sd_netlink_message *m;

Expand Down
3 changes: 3 additions & 0 deletions src/libsystemd/sd-netlink/netlink-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "ordered-set.h"
#include "socket-util.h"

#define RTA_FLAGS(rta) ((rta)->rta_type & ~NLA_TYPE_MASK)
#define RTA_TYPE(rta) ((rta)->rta_type & NLA_TYPE_MASK)

/* See struct rtvia in rtnetlink.h */
typedef struct RouteVia {
uint16_t family;
Expand Down
2 changes: 0 additions & 2 deletions src/network/networkd-bridge-vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,6 @@ int bridge_vlan_set_message(Link *link, sd_netlink_message *m, bool is_set) {
return 0;
}

#define RTA_TYPE(rta) ((rta)->rta_type & NLA_TYPE_MASK)

int link_update_bridge_vlan(Link *link, sd_netlink_message *m) {
_cleanup_free_ void *data = NULL;
size_t len;
Expand Down
1 change: 1 addition & 0 deletions src/systemd/sd-netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned short *type);
int sd_rtnl_message_new_route(sd_netlink *nl, sd_netlink_message **ret, uint16_t nlmsg_type, int rtm_family, unsigned char rtm_protocol);
int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char prefixlen);
int sd_rtnl_message_route_set_tos(sd_netlink_message *m, unsigned char tos);
int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope);
int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags);
int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table);
Expand Down

0 comments on commit 7c2e495

Please sign in to comment.