Commit 4430b897a2063c44462e8cea3293ebb5851d9cfd

Authored by Pablo Neira Ayuso
1 parent 7052ba4080

netfilter: cttimeout: remove superfluous check on layer 4 netlink functions

We assume they are always set accordingly since a874752a10da
("netfilter: conntrack: timeout interface depend on
CONFIG_NF_CONNTRACK_TIMEOUT"), so we can get rid of this checks.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

Showing 2 changed files with 18 additions and 33 deletions Side-by-side Diff

net/netfilter/nfnetlink_cttimeout.c
... ... @@ -53,9 +53,6 @@
53 53 struct nlattr **tb;
54 54 int ret = 0;
55 55  
56   - if (!l4proto->ctnl_timeout.nlattr_to_obj)
57   - return 0;
58   -
59 56 tb = kcalloc(l4proto->ctnl_timeout.nlattr_max + 1, sizeof(*tb),
60 57 GFP_KERNEL);
61 58  
... ... @@ -167,6 +164,8 @@
167 164 struct nfgenmsg *nfmsg;
168 165 unsigned int flags = portid ? NLM_F_MULTI : 0;
169 166 const struct nf_conntrack_l4proto *l4proto = timeout->timeout.l4proto;
  167 + struct nlattr *nest_parms;
  168 + int ret;
170 169  
171 170 event = nfnl_msg_type(NFNL_SUBSYS_CTNETLINK_TIMEOUT, event);
172 171 nlh = nlmsg_put(skb, portid, seq, event, sizeof(*nfmsg), flags);
173 172  
174 173  
175 174  
... ... @@ -186,23 +185,16 @@
186 185 htonl(refcount_read(&timeout->refcnt))))
187 186 goto nla_put_failure;
188 187  
189   - if (likely(l4proto->ctnl_timeout.obj_to_nlattr)) {
190   - struct nlattr *nest_parms;
191   - int ret;
  188 + nest_parms = nla_nest_start(skb, CTA_TIMEOUT_DATA | NLA_F_NESTED);
  189 + if (!nest_parms)
  190 + goto nla_put_failure;
192 191  
193   - nest_parms = nla_nest_start(skb,
194   - CTA_TIMEOUT_DATA | NLA_F_NESTED);
195   - if (!nest_parms)
196   - goto nla_put_failure;
  192 + ret = l4proto->ctnl_timeout.obj_to_nlattr(skb, &timeout->timeout.data);
  193 + if (ret < 0)
  194 + goto nla_put_failure;
197 195  
198   - ret = l4proto->ctnl_timeout.obj_to_nlattr(skb,
199   - &timeout->timeout.data);
200   - if (ret < 0)
201   - goto nla_put_failure;
  196 + nla_nest_end(skb, nest_parms);
202 197  
203   - nla_nest_end(skb, nest_parms);
204   - }
205   -
206 198 nlmsg_end(skb, nlh);
207 199 return skb->len;
208 200  
... ... @@ -397,6 +389,8 @@
397 389 struct nlmsghdr *nlh;
398 390 struct nfgenmsg *nfmsg;
399 391 unsigned int flags = portid ? NLM_F_MULTI : 0;
  392 + struct nlattr *nest_parms;
  393 + int ret;
400 394  
401 395 event = nfnl_msg_type(NFNL_SUBSYS_CTNETLINK_TIMEOUT, event);
402 396 nlh = nlmsg_put(skb, portid, seq, event, sizeof(*nfmsg), flags);
403 397  
404 398  
... ... @@ -412,21 +406,15 @@
412 406 nla_put_u8(skb, CTA_TIMEOUT_L4PROTO, l4proto->l4proto))
413 407 goto nla_put_failure;
414 408  
415   - if (likely(l4proto->ctnl_timeout.obj_to_nlattr)) {
416   - struct nlattr *nest_parms;
417   - int ret;
  409 + nest_parms = nla_nest_start(skb, CTA_TIMEOUT_DATA | NLA_F_NESTED);
  410 + if (!nest_parms)
  411 + goto nla_put_failure;
418 412  
419   - nest_parms = nla_nest_start(skb,
420   - CTA_TIMEOUT_DATA | NLA_F_NESTED);
421   - if (!nest_parms)
422   - goto nla_put_failure;
  413 + ret = l4proto->ctnl_timeout.obj_to_nlattr(skb, NULL);
  414 + if (ret < 0)
  415 + goto nla_put_failure;
423 416  
424   - ret = l4proto->ctnl_timeout.obj_to_nlattr(skb, NULL);
425   - if (ret < 0)
426   - goto nla_put_failure;
427   -
428   - nla_nest_end(skb, nest_parms);
429   - }
  417 + nla_nest_end(skb, nest_parms);
430 418  
431 419 nlmsg_end(skb, nlh);
432 420 return skb->len;
net/netfilter/nft_ct.c
... ... @@ -776,9 +776,6 @@
776 776 struct nlattr **tb;
777 777 int ret = 0;
778 778  
779   - if (!l4proto->ctnl_timeout.nlattr_to_obj)
780   - return 0;
781   -
782 779 tb = kcalloc(l4proto->ctnl_timeout.nlattr_max + 1, sizeof(*tb),
783 780 GFP_KERNEL);
784 781