Skip to content

Commit b12c97d

Browse files
jahurleydavem330
authored andcommitted
nfp: flower: fix cb_ident duplicate in indirect block register
Previously the identifier used for indirect block callback registry and for block rule cb registry (when done via indirect blocks) was the pointer to the netdev we were interested in receiving updates on. This worked fine if a single app existed that registered one callback per netdev of interest. However, if multiple cards are in place and, in turn, multiple apps, then each app may register the same callback with the same identifier to both the netdev's indirect block cb list and to a block's cb list. This can lead to EEXIST errors and/or incorrect cb deletions. Prevent this conflict by using the app pointer as the identifier for netdev indirect block cb registry, allowing each app to register a unique callback per netdev. For block cb registry, the same app may register multiple cbs to the same block if using TC shared blocks. Instead of the app, use the pointer to the allocated cb_priv data as the identifier here. This means that there can be a unique block callback for each app/netdev combo. Fixes: 3166dd0 ("nfp: flower: offload tunnel decap rules via indirect TC blocks") Reported-by: Edward Cree <ecree@solarflare.com> Signed-off-by: John Hurley <john.hurley@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d1675a1 commit b12c97d

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

  • drivers/net/ethernet/netronome/nfp/flower

‎drivers/net/ethernet/netronome/nfp/flower/offload.c‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -718,21 +718,23 @@ nfp_flower_setup_indr_tc_block(struct net_device *netdev, struct nfp_app *app,
718718

719719
err = tcf_block_cb_register(f->block,
720720
nfp_flower_setup_indr_block_cb,
721-
netdev, cb_priv, f->extack);
721+
cb_priv, cb_priv, f->extack);
722722
if (err) {
723723
list_del(&cb_priv->list);
724724
kfree(cb_priv);
725725
}
726726

727727
return err;
728728
case TC_BLOCK_UNBIND:
729-
tcf_block_cb_unregister(f->block,
730-
nfp_flower_setup_indr_block_cb, netdev);
731729
cb_priv = nfp_flower_indr_block_cb_priv_lookup(app, netdev);
732-
if (cb_priv) {
733-
list_del(&cb_priv->list);
734-
kfree(cb_priv);
735-
}
730+
if (!cb_priv)
731+
return -ENOENT;
732+
733+
tcf_block_cb_unregister(f->block,
734+
nfp_flower_setup_indr_block_cb,
735+
cb_priv);
736+
list_del(&cb_priv->list);
737+
kfree(cb_priv);
736738

737739
return 0;
738740
default:
@@ -766,15 +768,14 @@ int nfp_flower_reg_indir_block_handler(struct nfp_app *app,
766768
if (event == NETDEV_REGISTER) {
767769
err = __tc_indr_block_cb_register(netdev, app,
768770
nfp_flower_indr_setup_tc_cb,
769-
netdev);
771+
app);
770772
if (err)
771773
nfp_flower_cmsg_warn(app,
772774
"Indirect block reg failed - %s\n",
773775
netdev->name);
774776
} else if (event == NETDEV_UNREGISTER) {
775777
__tc_indr_block_cb_unregister(netdev,
776-
nfp_flower_indr_setup_tc_cb,
777-
netdev);
778+
nfp_flower_indr_setup_tc_cb, app);
778779
}
779780

780781
return NOTIFY_OK;

0 commit comments

Comments
 (0)