diff options
author | Thomas Graf <tgraf@suug.ch> | 2010-10-28 23:34:15 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2010-10-28 23:34:15 (GMT) |
commit | ee88c71d16a6b777c916275401a971eea78871d6 (patch) | |
tree | 45c158dd7548631f9a606f9fa75ed4becec4fc6b | |
parent | 897828de325d2f41d3d1008c240f14a572312221 (diff) | |
download | libnl-ee88c71d16a6b777c916275401a971eea78871d6.zip libnl-ee88c71d16a6b777c916275401a971eea78871d6.tar.gz libnl-ee88c71d16a6b777c916275401a971eea78871d6.tar.bz2 |
routing rules: mark support
Obsolete RTA_PROTOINFO code and parse RTA_MARK
rtnl_rule_set_mark(rule, mark)
rtnl_rule_get_mark(rule)
now access the mark as in firewall mark
-rw-r--r-- | include/netlink-types.h | 2 | ||||
-rw-r--r-- | include/netlink/route/rule.h | 4 | ||||
-rw-r--r-- | lib/route/rule.c | 26 |
3 files changed, 13 insertions, 19 deletions
diff --git a/include/netlink-types.h b/include/netlink-types.h index 3dc760f..d756d71 100644 --- a/include/netlink-types.h +++ b/include/netlink-types.h @@ -282,7 +282,7 @@ struct rtnl_rule { NLHDR_COMMON - uint64_t r_mark; + uint32_t r_mark; uint32_t r_prio; uint32_t r_realms; uint32_t r_table; diff --git a/include/netlink/route/rule.h b/include/netlink/route/rule.h index 928dc0f..a0729b5 100644 --- a/include/netlink/route/rule.h +++ b/include/netlink/route/rule.h @@ -44,8 +44,8 @@ extern void rtnl_rule_set_family(struct rtnl_rule *, int); extern int rtnl_rule_get_family(struct rtnl_rule *); extern void rtnl_rule_set_prio(struct rtnl_rule *, int); extern int rtnl_rule_get_prio(struct rtnl_rule *); -extern void rtnl_rule_set_mark(struct rtnl_rule *, uint64_t); -extern uint64_t rtnl_rule_get_mark(struct rtnl_rule *); +extern void rtnl_rule_set_mark(struct rtnl_rule *, uint32_t); +extern uint32_t rtnl_rule_get_mark(struct rtnl_rule *); extern void rtnl_rule_set_table(struct rtnl_rule *, int); extern int rtnl_rule_get_table(struct rtnl_rule *); extern void rtnl_rule_set_dsfield(struct rtnl_rule *, int); diff --git a/lib/route/rule.c b/lib/route/rule.c index 182879f..381c584 100644 --- a/lib/route/rule.c +++ b/lib/route/rule.c @@ -72,9 +72,9 @@ static int rule_clone(struct nl_object *_dst, struct nl_object *_src) static struct nla_policy rule_policy[RTA_MAX+1] = { [RTA_PRIORITY] = { .type = NLA_U32 }, [RTA_FLOW] = { .type = NLA_U32 }, - [RTA_PROTOINFO] = { .type = NLA_U32 }, [RTA_IIF] = { .type = NLA_STRING, .maxlen = IFNAMSIZ, }, + [RTA_MARK] = { .type = NLA_U32 }, }; static int rule_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, @@ -127,11 +127,6 @@ static int rule_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, rule->ce_mask |= RULE_ATTR_DST; } - if (tb[RTA_PROTOINFO]) { - rule->r_mark = nla_get_u32(tb[RTA_PROTOINFO]); - rule->ce_mask |= RULE_ATTR_MARK; - } - if (tb[RTA_IIF]) { nla_strlcpy(rule->r_iif, tb[RTA_IIF], IFNAMSIZ); rule->ce_mask |= RULE_ATTR_IIF; @@ -154,6 +149,11 @@ static int rule_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, rule->ce_mask |= RULE_ATTR_TABLE; } + if (tb[RTA_MARK]) { + rule->r_mark = nla_get_u32(tb[RTA_MARK]); + rule->ce_mask |= RULE_ATTR_MARK; + } + err = pp->pp_cb((struct nl_object *) rule, pp); errout: rtnl_rule_put(rule); @@ -193,7 +193,7 @@ static void rule_dump_line(struct nl_object *o, struct nl_dump_params *p) nl_dump(p, "tos %d ", r->r_dsfield); if (r->ce_mask & RULE_ATTR_MARK) - nl_dump(p, "mark %" PRIx64 , r->r_mark); + nl_dump(p, "mark %#x", r->r_mark); if (r->ce_mask & RULE_ATTR_IIF) nl_dump(p, "iif %s ", r->r_iif); @@ -381,9 +381,6 @@ static int build_rule_msg(struct rtnl_rule *tmpl, int cmd, int flags, if (tmpl->ce_mask & RULE_ATTR_PRIO) NLA_PUT_U32(msg, RTA_PRIORITY, tmpl->r_prio); - if (tmpl->ce_mask & RULE_ATTR_MARK) - NLA_PUT_U32(msg, RTA_PROTOINFO, tmpl->r_mark); - if (tmpl->ce_mask & RULE_ATTR_REALMS) NLA_PUT_U32(msg, RTA_FLOW, tmpl->r_realms); @@ -535,18 +532,15 @@ int rtnl_rule_get_prio(struct rtnl_rule *rule) return -1; } -void rtnl_rule_set_mark(struct rtnl_rule *rule, uint64_t mark) +void rtnl_rule_set_mark(struct rtnl_rule *rule, uint32_t mark) { rule->r_mark = mark; rule->ce_mask |= RULE_ATTR_MARK; } -uint64_t rtnl_rule_get_mark(struct rtnl_rule *rule) +uint32_t rtnl_rule_get_mark(struct rtnl_rule *rule) { - if (rule->ce_mask & RULE_ATTR_MARK) - return rule->r_mark; - else - return UINT_LEAST64_MAX; + return rule->r_mark; } void rtnl_rule_set_table(struct rtnl_rule *rule, int table) |