diff options
author | Romary Sonrier <romary@sonrier.com> | 2011-05-03 11:26:21 +0200 |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2011-05-03 11:40:21 +0200 |
commit | cb6a089d80df51f8bcd1a1cf6637174fdf483954 (patch) | |
tree | 6f9dc4b491e25ab5cd54000106eca91f9b16f2e6 | |
parent | cc33b0940f8ca0a34c9fbc085963e7887adc4db7 (diff) | |
download | libnl-cb6a089d80df51f8bcd1a1cf6637174fdf483954.tar.gz |
Adding rule with "From" option doesn't work
OK i found the bug, is is the patch !!
Can someone push it into the git tree ?
Regards,
Romary Sonrier
=========================
My analysis:
I guess that the pay load is *struct fib_rule_hdr*
struct fib_rule_hdr {
__u8 family;
__u8 dst_len;
__u8 src_len;
__u8 tos;
__u8 table;
__u8 res1; /* reserved */
__u8 res2; /* reserved */
__u8 action;
__u32 flags;
};
> [PAYLOAD] 12 octets
> 02 00 00 00 0a 00 00 01 00 00 00 00 ............
so
family = 02 , fine
table = 10, fine
but
src_len =0 !!!! should be 32
-rw-r--r-- | lib/route/rule.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/route/rule.c b/lib/route/rule.c index 8fa54e9..1a695cd 100644 --- a/lib/route/rule.c +++ b/lib/route/rule.c @@ -374,18 +374,20 @@ static int build_rule_msg(struct rtnl_rule *tmpl, int cmd, int flags, if (!msg) return -NLE_NOMEM; + if (tmpl->ce_mask & RULE_ATTR_SRC) + frh.src_len = nl_addr_get_prefixlen(tmpl->r_src); + + if (tmpl->ce_mask & RULE_ATTR_DST) + frh.dst_len = nl_addr_get_prefixlen(tmpl->r_dst); + if (nlmsg_append(msg, &frh, sizeof(frh), NLMSG_ALIGNTO) < 0) goto nla_put_failure; - if (tmpl->ce_mask & RULE_ATTR_SRC) { - frh.src_len = nl_addr_get_prefixlen(tmpl->r_src); + if (tmpl->ce_mask & RULE_ATTR_SRC) NLA_PUT_ADDR(msg, FRA_SRC, tmpl->r_src); - } - if (tmpl->ce_mask & RULE_ATTR_DST) { - frh.dst_len = nl_addr_get_prefixlen(tmpl->r_dst); + if (tmpl->ce_mask & RULE_ATTR_DST) NLA_PUT_ADDR(msg, FRA_DST, tmpl->r_dst); - } if (tmpl->ce_mask & RULE_ATTR_IIFNAME) NLA_PUT_STRING(msg, FRA_IIFNAME, tmpl->r_iifname); |