[PATCH] act: grab a reference when adding an action to a filter
Cong Wang
xiyou.wangcong at gmail.com
Mon Apr 14 18:39:09 PDT 2014
When we add an action to a filter, its lifetime becomes
same with the filter. So in case user frees it before
us, we could just grab a reference here.
Signed-off-by: Cong Wang <xiyou.wangcong at gmail.com>
---
lib/route/cls/basic.c | 2 ++
lib/route/cls/u32.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/lib/route/cls/basic.c b/lib/route/cls/basic.c
index 5a67fae..ae93d31 100644
--- a/lib/route/cls/basic.c
+++ b/lib/route/cls/basic.c
@@ -228,6 +228,8 @@ int rtnl_basic_add_action(struct rtnl_cls *cls, struct rtnl_act *act)
return -NLE_NOMEM;
b->b_mask |= BASIC_ATTR_ACTION;
+ /* In case user frees it */
+ nl_object_get(OBJ_CAST(act));
return rtnl_act_append(&b->b_act, act);
}
diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c
index 52ab263..d342131 100644
--- a/lib/route/cls/u32.c
+++ b/lib/route/cls/u32.c
@@ -470,6 +470,8 @@ int rtnl_u32_add_action(struct rtnl_cls *cls, struct rtnl_act *act)
return -NLE_NOMEM;
u->cu_mask |= U32_ATTR_ACTION;
+ /* In case user frees it */
+ nl_object_get(OBJ_CAST(act));
return rtnl_act_append(&u->cu_act, act);
}
--
1.8.3.1
More information about the libnl
mailing list