diff options
author | Serhey Popovych <serhe.popovych@gmail.com> | 2018-01-31 10:15:08 +0200 |
---|---|---|
committer | David Ahern <dsahern@gmail.com> | 2018-02-02 15:01:09 -0800 |
commit | c14f9d92eee107fb9392ea262734cf430de5b571 (patch) | |
tree | 57073071c3667d424c2060a40ddc93a0501b8890 /tc/m_ematch.c | |
parent | 28254695d1f33ed45f7e5dfe3bffe9f94bf6ab18 (diff) |
treewide: Use addattr_nest()/addattr_nest_end() to handle nested attributes
We have helper routines to support nested attribute addition into
netlink buffer: use them instead of open coding.
Use addattr_nest_compat()/addattr_nest_compat_end() where appropriate.
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
Diffstat (limited to 'tc/m_ematch.c')
-rw-r--r-- | tc/m_ematch.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/tc/m_ematch.c b/tc/m_ematch.c index d2bb5c38..7dbc2e75 100644 --- a/tc/m_ematch.c +++ b/tc/m_ematch.c @@ -175,13 +175,13 @@ static int parse_tree(struct nlmsghdr *n, struct ematch *tree) struct ematch *t; for (t = tree; t; t = t->next) { - struct rtattr *tail = NLMSG_TAIL(n); + struct rtattr *tail; struct tcf_ematch_hdr hdr = { .flags = t->relation }; if (t->inverted) hdr.flags |= TCF_EM_INVERT; - addattr_l(n, MAX_MSG, index++, NULL, 0); + tail = addattr_nest(n, MAX_MSG, index++); if (t->child) { __u32 r = t->child_ref; @@ -216,7 +216,7 @@ static int parse_tree(struct nlmsghdr *n, struct ematch *tree) return -1; } - tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; + addattr_nest_end(n, tail); } return 0; @@ -341,18 +341,16 @@ int parse_ematch(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n) .progid = TCF_EM_PROG_TC }; - tail = NLMSG_TAIL(n); - addattr_l(n, MAX_MSG, tca_id, NULL, 0); + tail = addattr_nest(n, MAX_MSG, tca_id); addattr_l(n, MAX_MSG, TCA_EMATCH_TREE_HDR, &hdr, sizeof(hdr)); - tail_list = NLMSG_TAIL(n); - addattr_l(n, MAX_MSG, TCA_EMATCH_TREE_LIST, NULL, 0); + tail_list = addattr_nest(n, MAX_MSG, TCA_EMATCH_TREE_LIST); if (parse_tree(n, ematch_root) < 0) return -1; - tail_list->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail_list; - tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; + addattr_nest_end(n, tail_list); + addattr_nest_end(n, tail); } *argc_p = ematch_argc; |