]> granicus.if.org Git - libnl/commitdiff
Adding rule with "From" option doesn't work
authorRomary Sonrier <romary@sonrier.com>
Tue, 3 May 2011 09:26:21 +0000 (11:26 +0200)
committerThomas Graf <tgraf@suug.ch>
Tue, 3 May 2011 09:40:21 +0000 (11:40 +0200)
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

lib/route/rule.c

index 8fa54e9927674f2a936f1f03686ea964568ee49e..1a695cd9396e62a27a4b93f7cad431076dfbd690 100644 (file)
@@ -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);