diff options
Diffstat (limited to 'zebra/rule_netlink.c')
| -rw-r--r-- | zebra/rule_netlink.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/zebra/rule_netlink.c b/zebra/rule_netlink.c index 8dbdc84589..b7be398506 100644 --- a/zebra/rule_netlink.c +++ b/zebra/rule_netlink.c @@ -87,38 +87,48 @@ static ssize_t netlink_rule_msg_encode( req->frh.family = family; req->frh.action = FR_ACT_TO_TBL; - nl_attr_put(&req->n, buflen, FRA_PROTOCOL, &protocol, sizeof(protocol)); + if (!nl_attr_put(&req->n, buflen, FRA_PROTOCOL, &protocol, + sizeof(protocol))) + return 0; /* rule's pref # */ - nl_attr_put32(&req->n, buflen, FRA_PRIORITY, priority); + if (!nl_attr_put32(&req->n, buflen, FRA_PRIORITY, priority)) + return 0; /* interface on which applied */ - nl_attr_put(&req->n, buflen, FRA_IFNAME, ifname, strlen(ifname) + 1); + if (!nl_attr_put(&req->n, buflen, FRA_IFNAME, ifname, + strlen(ifname) + 1)) + return 0; /* source IP, if specified */ if (filter_bm & PBR_FILTER_SRC_IP) { req->frh.src_len = src_ip->prefixlen; - nl_attr_put(&req->n, buflen, FRA_SRC, &src_ip->u.prefix, - bytelen); + if (!nl_attr_put(&req->n, buflen, FRA_SRC, &src_ip->u.prefix, + bytelen)) + return 0; } /* destination IP, if specified */ if (filter_bm & PBR_FILTER_DST_IP) { req->frh.dst_len = dst_ip->prefixlen; - nl_attr_put(&req->n, buflen, FRA_DST, &dst_ip->u.prefix, - bytelen); + if (!nl_attr_put(&req->n, buflen, FRA_DST, &dst_ip->u.prefix, + bytelen)) + return 0; } /* fwmark, if specified */ - if (filter_bm & PBR_FILTER_FWMARK) - nl_attr_put32(&req->n, buflen, FRA_FWMARK, fwmark); + if (filter_bm & PBR_FILTER_FWMARK) { + if (!nl_attr_put32(&req->n, buflen, FRA_FWMARK, fwmark)) + return 0; + } /* Route table to use to forward, if filter criteria matches. */ if (table < 256) req->frh.table = table; else { req->frh.table = RT_TABLE_UNSPEC; - nl_attr_put32(&req->n, buflen, FRA_TABLE, table); + if (!nl_attr_put32(&req->n, buflen, FRA_TABLE, table)) + return 0; } if (IS_ZEBRA_DEBUG_KERNEL) |
