@@ -1954,7 +1954,8 @@ static struct nft_hook *nft_hook_list_find(struct list_head *hook_list,
1954
1954
1955
1955
static int nf_tables_parse_netdev_hooks (struct net * net ,
1956
1956
const struct nlattr * attr ,
1957
- struct list_head * hook_list )
1957
+ struct list_head * hook_list ,
1958
+ struct netlink_ext_ack * extack )
1958
1959
{
1959
1960
struct nft_hook * hook , * next ;
1960
1961
const struct nlattr * tmp ;
@@ -1968,10 +1969,12 @@ static int nf_tables_parse_netdev_hooks(struct net *net,
1968
1969
1969
1970
hook = nft_netdev_hook_alloc (net , tmp );
1970
1971
if (IS_ERR (hook )) {
1972
+ NL_SET_BAD_ATTR (extack , tmp );
1971
1973
err = PTR_ERR (hook );
1972
1974
goto err_hook ;
1973
1975
}
1974
1976
if (nft_hook_list_find (hook_list , hook )) {
1977
+ NL_SET_BAD_ATTR (extack , tmp );
1975
1978
kfree (hook );
1976
1979
err = - EEXIST ;
1977
1980
goto err_hook ;
@@ -2004,20 +2007,23 @@ struct nft_chain_hook {
2004
2007
2005
2008
static int nft_chain_parse_netdev (struct net * net ,
2006
2009
struct nlattr * tb [],
2007
- struct list_head * hook_list )
2010
+ struct list_head * hook_list ,
2011
+ struct netlink_ext_ack * extack )
2008
2012
{
2009
2013
struct nft_hook * hook ;
2010
2014
int err ;
2011
2015
2012
2016
if (tb [NFTA_HOOK_DEV ]) {
2013
2017
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 ]);
2015
2020
return PTR_ERR (hook );
2021
+ }
2016
2022
2017
2023
list_add_tail (& hook -> list , hook_list );
2018
2024
} else if (tb [NFTA_HOOK_DEVS ]) {
2019
2025
err = nf_tables_parse_netdev_hooks (net , tb [NFTA_HOOK_DEVS ],
2020
- hook_list );
2026
+ hook_list , extack );
2021
2027
if (err < 0 )
2022
2028
return err ;
2023
2029
@@ -2085,7 +2091,7 @@ static int nft_chain_parse_hook(struct net *net,
2085
2091
2086
2092
INIT_LIST_HEAD (& hook -> list );
2087
2093
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 );
2089
2095
if (err < 0 ) {
2090
2096
module_put (type -> owner );
2091
2097
return err ;
@@ -7560,7 +7566,8 @@ static const struct nla_policy nft_flowtable_hook_policy[NFTA_FLOWTABLE_HOOK_MAX
7560
7566
static int nft_flowtable_parse_hook (const struct nft_ctx * ctx ,
7561
7567
const struct nlattr * attr ,
7562
7568
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 )
7564
7571
{
7565
7572
struct nlattr * tb [NFTA_FLOWTABLE_HOOK_MAX + 1 ];
7566
7573
struct nft_hook * hook ;
@@ -7607,7 +7614,8 @@ static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
7607
7614
if (tb [NFTA_FLOWTABLE_HOOK_DEVS ]) {
7608
7615
err = nf_tables_parse_netdev_hooks (ctx -> net ,
7609
7616
tb [NFTA_FLOWTABLE_HOOK_DEVS ],
7610
- & flowtable_hook -> list );
7617
+ & flowtable_hook -> list ,
7618
+ extack );
7611
7619
if (err < 0 )
7612
7620
return err ;
7613
7621
}
@@ -7750,7 +7758,8 @@ static void nft_flowtable_hooks_destroy(struct list_head *hook_list)
7750
7758
}
7751
7759
7752
7760
static 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 )
7754
7763
{
7755
7764
const struct nlattr * const * nla = ctx -> nla ;
7756
7765
struct nft_flowtable_hook flowtable_hook ;
@@ -7761,7 +7770,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
7761
7770
int err ;
7762
7771
7763
7772
err = nft_flowtable_parse_hook (ctx , nla [NFTA_FLOWTABLE_HOOK ],
7764
- & flowtable_hook , flowtable , false);
7773
+ & flowtable_hook , flowtable , extack , false);
7765
7774
if (err < 0 )
7766
7775
return err ;
7767
7776
@@ -7866,7 +7875,7 @@ static int nf_tables_newflowtable(struct sk_buff *skb,
7866
7875
7867
7876
nft_ctx_init (& ctx , net , skb , info -> nlh , family , table , NULL , nla );
7868
7877
7869
- return nft_flowtable_update (& ctx , info -> nlh , flowtable );
7878
+ return nft_flowtable_update (& ctx , info -> nlh , flowtable , extack );
7870
7879
}
7871
7880
7872
7881
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,
7907
7916
goto err3 ;
7908
7917
7909
7918
err = nft_flowtable_parse_hook (& ctx , nla [NFTA_FLOWTABLE_HOOK ],
7910
- & flowtable_hook , flowtable , true);
7919
+ & flowtable_hook , flowtable , extack , true);
7911
7920
if (err < 0 )
7912
7921
goto err4 ;
7913
7922
@@ -7959,7 +7968,8 @@ static void nft_flowtable_hook_release(struct nft_flowtable_hook *flowtable_hook
7959
7968
}
7960
7969
7961
7970
static int nft_delflowtable_hook (struct nft_ctx * ctx ,
7962
- struct nft_flowtable * flowtable )
7971
+ struct nft_flowtable * flowtable ,
7972
+ struct netlink_ext_ack * extack )
7963
7973
{
7964
7974
const struct nlattr * const * nla = ctx -> nla ;
7965
7975
struct nft_flowtable_hook flowtable_hook ;
@@ -7969,7 +7979,7 @@ static int nft_delflowtable_hook(struct nft_ctx *ctx,
7969
7979
int err ;
7970
7980
7971
7981
err = nft_flowtable_parse_hook (ctx , nla [NFTA_FLOWTABLE_HOOK ],
7972
- & flowtable_hook , flowtable , false);
7982
+ & flowtable_hook , flowtable , extack , false);
7973
7983
if (err < 0 )
7974
7984
return err ;
7975
7985
@@ -8051,7 +8061,7 @@ static int nf_tables_delflowtable(struct sk_buff *skb,
8051
8061
nft_ctx_init (& ctx , net , skb , info -> nlh , family , table , NULL , nla );
8052
8062
8053
8063
if (nla [NFTA_FLOWTABLE_HOOK ])
8054
- return nft_delflowtable_hook (& ctx , flowtable );
8064
+ return nft_delflowtable_hook (& ctx , flowtable , extack );
8055
8065
8056
8066
if (flowtable -> use > 0 ) {
8057
8067
NL_SET_BAD_ATTR (extack , attr );
0 commit comments