@@ -515,20 +515,15 @@ ctnetlink_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
515515{
516516 const struct nf_conntrack_zone * zone ;
517517 struct nlmsghdr * nlh ;
518- struct nfgenmsg * nfmsg ;
519518 struct nlattr * nest_parms ;
520519 unsigned int flags = portid ? NLM_F_MULTI : 0 , event ;
521520
522521 event = nfnl_msg_type (NFNL_SUBSYS_CTNETLINK , IPCTNL_MSG_CT_NEW );
523- nlh = nlmsg_put (skb , portid , seq , event , sizeof (* nfmsg ), flags );
524- if (nlh == NULL )
522+ nlh = nfnl_msg_put (skb , portid , seq , event , flags , nf_ct_l3num (ct ),
523+ NFNETLINK_V0 , 0 );
524+ if (!nlh )
525525 goto nlmsg_failure ;
526526
527- nfmsg = nlmsg_data (nlh );
528- nfmsg -> nfgen_family = nf_ct_l3num (ct );
529- nfmsg -> version = NFNETLINK_V0 ;
530- nfmsg -> res_id = 0 ;
531-
532527 zone = nf_ct_zone (ct );
533528
534529 nest_parms = nla_nest_start (skb , CTA_TUPLE_ORIG );
@@ -685,7 +680,6 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item)
685680 const struct nf_conntrack_zone * zone ;
686681 struct net * net ;
687682 struct nlmsghdr * nlh ;
688- struct nfgenmsg * nfmsg ;
689683 struct nlattr * nest_parms ;
690684 struct nf_conn * ct = item -> ct ;
691685 struct sk_buff * skb ;
@@ -715,15 +709,11 @@ ctnetlink_conntrack_event(unsigned int events, struct nf_ct_event *item)
715709 goto errout ;
716710
717711 type = nfnl_msg_type (NFNL_SUBSYS_CTNETLINK , type );
718- nlh = nlmsg_put (skb , item -> portid , 0 , type , sizeof (* nfmsg ), flags );
719- if (nlh == NULL )
712+ nlh = nfnl_msg_put (skb , item -> portid , 0 , type , flags , nf_ct_l3num (ct ),
713+ NFNETLINK_V0 , 0 );
714+ if (!nlh )
720715 goto nlmsg_failure ;
721716
722- nfmsg = nlmsg_data (nlh );
723- nfmsg -> nfgen_family = nf_ct_l3num (ct );
724- nfmsg -> version = NFNETLINK_V0 ;
725- nfmsg -> res_id = 0 ;
726-
727717 zone = nf_ct_zone (ct );
728718
729719 nest_parms = nla_nest_start (skb , CTA_TUPLE_ORIG );
@@ -2200,20 +2190,15 @@ ctnetlink_ct_stat_cpu_fill_info(struct sk_buff *skb, u32 portid, u32 seq,
22002190 __u16 cpu , const struct ip_conntrack_stat * st )
22012191{
22022192 struct nlmsghdr * nlh ;
2203- struct nfgenmsg * nfmsg ;
22042193 unsigned int flags = portid ? NLM_F_MULTI : 0 , event ;
22052194
22062195 event = nfnl_msg_type (NFNL_SUBSYS_CTNETLINK ,
22072196 IPCTNL_MSG_CT_GET_STATS_CPU );
2208- nlh = nlmsg_put (skb , portid , seq , event , sizeof (* nfmsg ), flags );
2209- if (nlh == NULL )
2197+ nlh = nfnl_msg_put (skb , portid , seq , event , flags , AF_UNSPEC ,
2198+ NFNETLINK_V0 , htons (cpu ));
2199+ if (!nlh )
22102200 goto nlmsg_failure ;
22112201
2212- nfmsg = nlmsg_data (nlh );
2213- nfmsg -> nfgen_family = AF_UNSPEC ;
2214- nfmsg -> version = NFNETLINK_V0 ;
2215- nfmsg -> res_id = htons (cpu );
2216-
22172202 if (nla_put_be32 (skb , CTA_STATS_FOUND , htonl (st -> found )) ||
22182203 nla_put_be32 (skb , CTA_STATS_INVALID , htonl (st -> invalid )) ||
22192204 nla_put_be32 (skb , CTA_STATS_IGNORE , htonl (st -> ignore )) ||
@@ -2284,20 +2269,15 @@ ctnetlink_stat_ct_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
22842269 struct net * net )
22852270{
22862271 struct nlmsghdr * nlh ;
2287- struct nfgenmsg * nfmsg ;
22882272 unsigned int flags = portid ? NLM_F_MULTI : 0 , event ;
22892273 unsigned int nr_conntracks = atomic_read (& net -> ct .count );
22902274
22912275 event = nfnl_msg_type (NFNL_SUBSYS_CTNETLINK , IPCTNL_MSG_CT_GET_STATS );
2292- nlh = nlmsg_put (skb , portid , seq , event , sizeof (* nfmsg ), flags );
2293- if (nlh == NULL )
2276+ nlh = nfnl_msg_put (skb , portid , seq , event , flags , AF_UNSPEC ,
2277+ NFNETLINK_V0 , 0 );
2278+ if (!nlh )
22942279 goto nlmsg_failure ;
22952280
2296- nfmsg = nlmsg_data (nlh );
2297- nfmsg -> nfgen_family = AF_UNSPEC ;
2298- nfmsg -> version = NFNETLINK_V0 ;
2299- nfmsg -> res_id = 0 ;
2300-
23012281 if (nla_put_be32 (skb , CTA_STATS_GLOBAL_ENTRIES , htonl (nr_conntracks )))
23022282 goto nla_put_failure ;
23032283
@@ -2803,19 +2783,14 @@ ctnetlink_exp_fill_info(struct sk_buff *skb, u32 portid, u32 seq,
28032783 int event , const struct nf_conntrack_expect * exp )
28042784{
28052785 struct nlmsghdr * nlh ;
2806- struct nfgenmsg * nfmsg ;
28072786 unsigned int flags = portid ? NLM_F_MULTI : 0 ;
28082787
28092788 event = nfnl_msg_type (NFNL_SUBSYS_CTNETLINK_EXP , event );
2810- nlh = nlmsg_put (skb , portid , seq , event , sizeof (* nfmsg ), flags );
2811- if (nlh == NULL )
2789+ nlh = nfnl_msg_put (skb , portid , seq , event , flags ,
2790+ exp -> tuple .src .l3num , NFNETLINK_V0 , 0 );
2791+ if (!nlh )
28122792 goto nlmsg_failure ;
28132793
2814- nfmsg = nlmsg_data (nlh );
2815- nfmsg -> nfgen_family = exp -> tuple .src .l3num ;
2816- nfmsg -> version = NFNETLINK_V0 ;
2817- nfmsg -> res_id = 0 ;
2818-
28192794 if (ctnetlink_exp_dump_expect (skb , exp ) < 0 )
28202795 goto nla_put_failure ;
28212796
@@ -2835,7 +2810,6 @@ ctnetlink_expect_event(unsigned int events, struct nf_exp_event *item)
28352810 struct nf_conntrack_expect * exp = item -> exp ;
28362811 struct net * net = nf_ct_exp_net (exp );
28372812 struct nlmsghdr * nlh ;
2838- struct nfgenmsg * nfmsg ;
28392813 struct sk_buff * skb ;
28402814 unsigned int type , group ;
28412815 int flags = 0 ;
@@ -2858,15 +2832,11 @@ ctnetlink_expect_event(unsigned int events, struct nf_exp_event *item)
28582832 goto errout ;
28592833
28602834 type = nfnl_msg_type (NFNL_SUBSYS_CTNETLINK_EXP , type );
2861- nlh = nlmsg_put (skb , item -> portid , 0 , type , sizeof (* nfmsg ), flags );
2862- if (nlh == NULL )
2835+ nlh = nfnl_msg_put (skb , item -> portid , 0 , type , flags ,
2836+ exp -> tuple .src .l3num , NFNETLINK_V0 , 0 );
2837+ if (!nlh )
28632838 goto nlmsg_failure ;
28642839
2865- nfmsg = nlmsg_data (nlh );
2866- nfmsg -> nfgen_family = exp -> tuple .src .l3num ;
2867- nfmsg -> version = NFNETLINK_V0 ;
2868- nfmsg -> res_id = 0 ;
2869-
28702840 if (ctnetlink_exp_dump_expect (skb , exp ) < 0 )
28712841 goto nla_put_failure ;
28722842
@@ -3436,20 +3406,15 @@ ctnetlink_exp_stat_fill_info(struct sk_buff *skb, u32 portid, u32 seq, int cpu,
34363406 const struct ip_conntrack_stat * st )
34373407{
34383408 struct nlmsghdr * nlh ;
3439- struct nfgenmsg * nfmsg ;
34403409 unsigned int flags = portid ? NLM_F_MULTI : 0 , event ;
34413410
34423411 event = nfnl_msg_type (NFNL_SUBSYS_CTNETLINK ,
34433412 IPCTNL_MSG_EXP_GET_STATS_CPU );
3444- nlh = nlmsg_put (skb , portid , seq , event , sizeof (* nfmsg ), flags );
3445- if (nlh == NULL )
3413+ nlh = nfnl_msg_put (skb , portid , seq , event , flags , AF_UNSPEC ,
3414+ NFNETLINK_V0 , htons (cpu ));
3415+ if (!nlh )
34463416 goto nlmsg_failure ;
34473417
3448- nfmsg = nlmsg_data (nlh );
3449- nfmsg -> nfgen_family = AF_UNSPEC ;
3450- nfmsg -> version = NFNETLINK_V0 ;
3451- nfmsg -> res_id = htons (cpu );
3452-
34533418 if (nla_put_be32 (skb , CTA_STATS_EXP_NEW , htonl (st -> expect_new )) ||
34543419 nla_put_be32 (skb , CTA_STATS_EXP_CREATE , htonl (st -> expect_create )) ||
34553420 nla_put_be32 (skb , CTA_STATS_EXP_DELETE , htonl (st -> expect_delete )))
0 commit comments