@@ -6195,7 +6195,7 @@ static const struct nla_policy nft_flowtable_hook_policy[NFTA_FLOWTABLE_HOOK_MAX
61956195static int nft_flowtable_parse_hook (const struct nft_ctx * ctx ,
61966196 const struct nlattr * attr ,
61976197 struct nft_flowtable_hook * flowtable_hook ,
6198- struct nf_flowtable * ft )
6198+ struct nft_flowtable * flowtable , bool add )
61996199{
62006200 struct nlattr * tb [NFTA_FLOWTABLE_HOOK_MAX + 1 ];
62016201 struct nft_hook * hook ;
@@ -6209,15 +6209,35 @@ static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
62096209 if (err < 0 )
62106210 return err ;
62116211
6212- if (!tb [NFTA_FLOWTABLE_HOOK_NUM ] ||
6213- !tb [NFTA_FLOWTABLE_HOOK_PRIORITY ])
6214- return - EINVAL ;
6212+ if (add ) {
6213+ if (!tb [NFTA_FLOWTABLE_HOOK_NUM ] ||
6214+ !tb [NFTA_FLOWTABLE_HOOK_PRIORITY ])
6215+ return - EINVAL ;
62156216
6216- hooknum = ntohl (nla_get_be32 (tb [NFTA_FLOWTABLE_HOOK_NUM ]));
6217- if (hooknum != NF_NETDEV_INGRESS )
6218- return - EINVAL ;
6217+ hooknum = ntohl (nla_get_be32 (tb [NFTA_FLOWTABLE_HOOK_NUM ]));
6218+ if (hooknum != NF_NETDEV_INGRESS )
6219+ return - EOPNOTSUPP ;
6220+
6221+ priority = ntohl (nla_get_be32 (tb [NFTA_FLOWTABLE_HOOK_PRIORITY ]));
6222+
6223+ flowtable_hook -> priority = priority ;
6224+ flowtable_hook -> num = hooknum ;
6225+ } else {
6226+ if (tb [NFTA_FLOWTABLE_HOOK_NUM ]) {
6227+ hooknum = ntohl (nla_get_be32 (tb [NFTA_FLOWTABLE_HOOK_NUM ]));
6228+ if (hooknum != flowtable -> hooknum )
6229+ return - EOPNOTSUPP ;
6230+ }
6231+
6232+ if (tb [NFTA_FLOWTABLE_HOOK_PRIORITY ]) {
6233+ priority = ntohl (nla_get_be32 (tb [NFTA_FLOWTABLE_HOOK_PRIORITY ]));
6234+ if (priority != flowtable -> data .priority )
6235+ return - EOPNOTSUPP ;
6236+ }
62196237
6220- priority = ntohl (nla_get_be32 (tb [NFTA_FLOWTABLE_HOOK_PRIORITY ]));
6238+ flowtable_hook -> priority = flowtable -> data .priority ;
6239+ flowtable_hook -> num = flowtable -> hooknum ;
6240+ }
62216241
62226242 if (tb [NFTA_FLOWTABLE_HOOK_DEVS ]) {
62236243 err = nf_tables_parse_netdev_hooks (ctx -> net ,
@@ -6227,15 +6247,12 @@ static int nft_flowtable_parse_hook(const struct nft_ctx *ctx,
62276247 return err ;
62286248 }
62296249
6230- flowtable_hook -> priority = priority ;
6231- flowtable_hook -> num = hooknum ;
6232-
62336250 list_for_each_entry (hook , & flowtable_hook -> list , list ) {
62346251 hook -> ops .pf = NFPROTO_NETDEV ;
6235- hook -> ops .hooknum = hooknum ;
6236- hook -> ops .priority = priority ;
6237- hook -> ops .priv = ft ;
6238- hook -> ops .hook = ft -> type -> hook ;
6252+ hook -> ops .hooknum = flowtable_hook -> num ;
6253+ hook -> ops .priority = flowtable_hook -> priority ;
6254+ hook -> ops .priv = & flowtable -> data ;
6255+ hook -> ops .hook = flowtable -> data . type -> hook ;
62396256 }
62406257
62416258 return err ;
@@ -6363,7 +6380,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
63636380 int err ;
63646381
63656382 err = nft_flowtable_parse_hook (ctx , nla [NFTA_FLOWTABLE_HOOK ],
6366- & flowtable_hook , & flowtable -> data );
6383+ & flowtable_hook , flowtable , false );
63676384 if (err < 0 )
63686385 return err ;
63696386
@@ -6492,7 +6509,7 @@ static int nf_tables_newflowtable(struct net *net, struct sock *nlsk,
64926509 goto err3 ;
64936510
64946511 err = nft_flowtable_parse_hook (& ctx , nla [NFTA_FLOWTABLE_HOOK ],
6495- & flowtable_hook , & flowtable -> data );
6512+ & flowtable_hook , flowtable , true );
64966513 if (err < 0 )
64976514 goto err4 ;
64986515
@@ -6543,7 +6560,7 @@ static int nft_delflowtable_hook(struct nft_ctx *ctx,
65436560 int err ;
65446561
65456562 err = nft_flowtable_parse_hook (ctx , nla [NFTA_FLOWTABLE_HOOK ],
6546- & flowtable_hook , & flowtable -> data );
6563+ & flowtable_hook , flowtable , false );
65476564 if (err < 0 )
65486565 return err ;
65496566
0 commit comments