@@ -1954,7 +1954,8 @@ static struct nft_hook *nft_hook_list_find(struct list_head *hook_list,
19541954
19551955static int nf_tables_parse_netdev_hooks (struct net * net ,
19561956 const struct nlattr * attr ,
1957- struct list_head * hook_list )
1957+ struct list_head * hook_list ,
1958+ struct netlink_ext_ack * extack )
19581959{
19591960 struct nft_hook * hook , * next ;
19601961 const struct nlattr * tmp ;
@@ -1968,10 +1969,12 @@ static int nf_tables_parse_netdev_hooks(struct net *net,
19681969
19691970 hook = nft_netdev_hook_alloc (net , tmp );
19701971 if (IS_ERR (hook )) {
1972+ NL_SET_BAD_ATTR (extack , tmp );
19711973 err = PTR_ERR (hook );
19721974 goto err_hook ;
19731975 }
19741976 if (nft_hook_list_find (hook_list , hook )) {
1977+ NL_SET_BAD_ATTR (extack , tmp );
19751978 kfree (hook );
19761979 err = - EEXIST ;
19771980 goto err_hook ;
@@ -2004,20 +2007,23 @@ struct nft_chain_hook {
20042007
20052008static int nft_chain_parse_netdev (struct net * net ,
20062009 struct nlattr * tb [],
2007- struct list_head * hook_list )
2010+ struct list_head * hook_list ,
2011+ struct netlink_ext_ack * extack )
20082012{
20092013 struct nft_hook * hook ;
20102014 int err ;
20112015
20122016 if (tb [NFTA_HOOK_DEV ]) {
20132017 hook = nft_netdev_hook_alloc (net , tb [NFTA_HOOK_DEV ]);
2014- if (IS_ERR (hook ))
2018+ if (IS_ERR (hook )) {
2019+ NL_SET_BAD_ATTR (extack , tb [NFTA_HOOK_DEV ]);
20152020 return PTR_ERR (hook );
2021+ }
20162022
20172023 list_add_tail (& hook -> list , hook_list );
20182024 } else if (tb [NFTA_HOOK_DEVS ]) {
20192025 err = nf_tables_parse_netdev_hooks (net , tb [NFTA_HOOK_DEVS ],
2020- hook_list );
2026+ hook_list , extack );
20212027 if (err < 0 )
20222028 return err ;
20232029
@@ -2085,7 +2091,7 @@ static int nft_chain_parse_hook(struct net *net,
20852091
20862092 INIT_LIST_HEAD (& hook -> list );
20872093 if (nft_base_chain_netdev (family , hook -> num )) {
2088- err = nft_chain_parse_netdev (net , ha , & hook -> list );
2094+ err = nft_chain_parse_netdev (net , ha , & hook -> list , extack );
20892095 if (err < 0 ) {
20902096 module_put (type -> owner );
20912097 return err ;
@@ -7560,7 +7566,8 @@ static const struct nla_policy nft_flowtable_hook_policy[NFTA_FLOWTABLE_HOOK_MAX
75607566static int nft_flowtable_parse_hook (const struct nft_ctx * ctx ,
75617567 const struct nlattr * attr ,
75627568 struct nft_flowtable_hook * flowtable_hook ,
7563- struct nft_flowtable * flowtable , bool add )
7569+ struct nft_flowtable * flowtable ,
7570+ struct netlink_ext_ack * extack , bool add )
75647571{
75657572 struct nlattr * tb [NFTA_FLOWTABLE_HOOK_MAX + 1 ];
75667573 struct nft_hook * hook ;
@@ -7607,7 +7614,8 @@ static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
76077614 if (tb [NFTA_FLOWTABLE_HOOK_DEVS ]) {
76087615 err = nf_tables_parse_netdev_hooks (ctx -> net ,
76097616 tb [NFTA_FLOWTABLE_HOOK_DEVS ],
7610- & flowtable_hook -> list );
7617+ & flowtable_hook -> list ,
7618+ extack );
76117619 if (err < 0 )
76127620 return err ;
76137621 }
@@ -7750,7 +7758,8 @@ static void nft_flowtable_hooks_destroy(struct list_head *hook_list)
77507758}
77517759
77527760static int nft_flowtable_update (struct nft_ctx * ctx , const struct nlmsghdr * nlh ,
7753- struct nft_flowtable * flowtable )
7761+ struct nft_flowtable * flowtable ,
7762+ struct netlink_ext_ack * extack )
77547763{
77557764 const struct nlattr * const * nla = ctx -> nla ;
77567765 struct nft_flowtable_hook flowtable_hook ;
@@ -7761,7 +7770,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
77617770 int err ;
77627771
77637772 err = nft_flowtable_parse_hook (ctx , nla [NFTA_FLOWTABLE_HOOK ],
7764- & flowtable_hook , flowtable , false);
7773+ & flowtable_hook , flowtable , extack , false);
77657774 if (err < 0 )
77667775 return err ;
77677776
@@ -7866,7 +7875,7 @@ static int nf_tables_newflowtable(struct sk_buff *skb,
78667875
78677876 nft_ctx_init (& ctx , net , skb , info -> nlh , family , table , NULL , nla );
78687877
7869- return nft_flowtable_update (& ctx , info -> nlh , flowtable );
7878+ return nft_flowtable_update (& ctx , info -> nlh , flowtable , extack );
78707879 }
78717880
78727881 nft_ctx_init (& ctx , net , skb , info -> nlh , family , table , NULL , nla );
@@ -7907,7 +7916,7 @@ static int nf_tables_newflowtable(struct sk_buff *skb,
79077916 goto err3 ;
79087917
79097918 err = nft_flowtable_parse_hook (& ctx , nla [NFTA_FLOWTABLE_HOOK ],
7910- & flowtable_hook , flowtable , true);
7919+ & flowtable_hook , flowtable , extack , true);
79117920 if (err < 0 )
79127921 goto err4 ;
79137922
@@ -7959,7 +7968,8 @@ static void nft_flowtable_hook_release(struct nft_flowtable_hook *flowtable_hook
79597968}
79607969
79617970static int nft_delflowtable_hook (struct nft_ctx * ctx ,
7962- struct nft_flowtable * flowtable )
7971+ struct nft_flowtable * flowtable ,
7972+ struct netlink_ext_ack * extack )
79637973{
79647974 const struct nlattr * const * nla = ctx -> nla ;
79657975 struct nft_flowtable_hook flowtable_hook ;
@@ -7969,7 +7979,7 @@ static int nft_delflowtable_hook(struct nft_ctx *ctx,
79697979 int err ;
79707980
79717981 err = nft_flowtable_parse_hook (ctx , nla [NFTA_FLOWTABLE_HOOK ],
7972- & flowtable_hook , flowtable , false);
7982+ & flowtable_hook , flowtable , extack , false);
79737983 if (err < 0 )
79747984 return err ;
79757985
@@ -8051,7 +8061,7 @@ static int nf_tables_delflowtable(struct sk_buff *skb,
80518061 nft_ctx_init (& ctx , net , skb , info -> nlh , family , table , NULL , nla );
80528062
80538063 if (nla [NFTA_FLOWTABLE_HOOK ])
8054- return nft_delflowtable_hook (& ctx , flowtable );
8064+ return nft_delflowtable_hook (& ctx , flowtable , extack );
80558065
80568066 if (flowtable -> use > 0 ) {
80578067 NL_SET_BAD_ATTR (extack , attr );
0 commit comments