Skip to content

Commit 09aa811

Browse files
jahurleydavem330
authored andcommitted
nfp: flower: remove offloaded MACs when reprs are applied to OvS bridges
MAC addresses along with an identifying index are offloaded to firmware to allow tunnel decapsulation. If a tunnel packet arrives with a matching destination MAC address and a verified index, it can continue on the decapsulation process. This replicates the MAC verifications carried out in the kernel network stack. When a netdev is added to a bridge (e.g. OvS) then packets arriving on that dev are directed through the bridge datapath instead of passing through the network stack. Therefore, tunnelled packets matching the MAC of that dev will not be decapped here. Replicate this behaviour on firmware by removing offloaded MAC addresses when a MAC representer is added to an OvS bridge. This can prevent any false positive tunnel decaps. Signed-off-by: John Hurley <john.hurley@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f12725d commit 09aa811

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

‎drivers/net/ethernet/netronome/nfp/flower/main.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ struct nfp_fl_qos {
221221
* @block_shared: Flag indicating if offload applies to shared blocks
222222
* @mac_list: List entry of reprs that share the same offloaded MAC
223223
* @qos_table: Stored info on filters implementing qos
224+
* @on_bridge: Indicates if the repr is attached to a bridge
224225
*/
225226
struct nfp_flower_repr_priv {
226227
struct nfp_repr *nfp_repr;
@@ -230,6 +231,7 @@ struct nfp_flower_repr_priv {
230231
bool block_shared;
231232
struct list_head mac_list;
232233
struct nfp_fl_qos qos_table;
234+
bool on_bridge;
233235
};
234236

235237
/**
@@ -341,6 +343,11 @@ static inline bool nfp_flower_is_merge_flow(struct nfp_fl_payload *flow_pay)
341343
return flow_pay->tc_flower_cookie == (unsigned long)flow_pay;
342344
}
343345

346+
static inline bool nfp_flower_is_supported_bridge(struct net_device *netdev)
347+
{
348+
return netif_is_ovs_master(netdev);
349+
}
350+
344351
int nfp_flower_metadata_init(struct nfp_app *app, u64 host_ctx_count,
345352
unsigned int host_ctx_split);
346353
void nfp_flower_metadata_cleanup(struct nfp_app *app);

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,9 @@ nfp_tunnel_offload_mac(struct nfp_app *app, struct net_device *netdev,
730730
return 0;
731731

732732
repr_priv = repr->app_priv;
733+
if (repr_priv->on_bridge)
734+
return 0;
735+
733736
mac_offloaded = &repr_priv->mac_offloaded;
734737
off_mac = &repr_priv->offloaded_mac_addr[0];
735738
port = nfp_repr_get_port_id(netdev);
@@ -845,6 +848,45 @@ int nfp_tunnel_mac_event_handler(struct nfp_app *app,
845848
if (err)
846849
nfp_flower_cmsg_warn(app, "Failed to offload MAC change on %s.\n",
847850
netdev_name(netdev));
851+
} else if (event == NETDEV_CHANGEUPPER) {
852+
/* If a repr is attached to a bridge then tunnel packets
853+
* entering the physical port are directed through the bridge
854+
* datapath and cannot be directly detunneled. Therefore,
855+
* associated offloaded MACs and indexes should not be used
856+
* by fw for detunneling.
857+
*/
858+
struct netdev_notifier_changeupper_info *info = ptr;
859+
struct net_device *upper = info->upper_dev;
860+
struct nfp_flower_repr_priv *repr_priv;
861+
struct nfp_repr *repr;
862+
863+
if (!nfp_netdev_is_nfp_repr(netdev) ||
864+
!nfp_flower_is_supported_bridge(upper))
865+
return NOTIFY_OK;
866+
867+
repr = netdev_priv(netdev);
868+
if (repr->app != app)
869+
return NOTIFY_OK;
870+
871+
repr_priv = repr->app_priv;
872+
873+
if (info->linking) {
874+
if (nfp_tunnel_offload_mac(app, netdev,
875+
NFP_TUNNEL_MAC_OFFLOAD_DEL))
876+
nfp_flower_cmsg_warn(app, "Failed to delete offloaded MAC on %s.\n",
877+
netdev_name(netdev));
878+
repr_priv->on_bridge = true;
879+
} else {
880+
repr_priv->on_bridge = false;
881+
882+
if (!(netdev->flags & IFF_UP))
883+
return NOTIFY_OK;
884+
885+
if (nfp_tunnel_offload_mac(app, netdev,
886+
NFP_TUNNEL_MAC_OFFLOAD_ADD))
887+
nfp_flower_cmsg_warn(app, "Failed to offload MAC on %s.\n",
888+
netdev_name(netdev));
889+
}
848890
}
849891
return NOTIFY_OK;
850892
}

0 commit comments

Comments
 (0)