Skip to content

Commit cf58aef

Browse files
qsnkuba-moo
authored andcommitted
macsec: don't increment counters for an unrelated SA
On RX, we shouldn't be incrementing the stats for an arbitrary SA in case the actual SA hasn't been set up. Those counters are intended to track packets for their respective AN when the SA isn't currently configured. Due to the way MACsec is implemented, we don't keep counters unless the SA is configured, so we can't track those packets, and those counters will remain at 0. The RXSC's stats keeps track of those packets without telling us which AN they belonged to. We could add counters for non-existent SAs, and then find a way to integrate them in the dump to userspace, but I don't think it's worth the effort. Fixes: 91ec9bd ("macsec: Fix traffic counters/statistics") Reported-by: Paolo Abeni <[email protected]> Signed-off-by: Sabrina Dubroca <[email protected]> Link: https://patch.msgid.link/f5ac92aaa5b89343232615f4c03f9f95042c6aa0.1728657709.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 637c4f6 commit cf58aef

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

drivers/net/macsec.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,6 @@ static struct macsec_rx_sa *macsec_rxsa_get(struct macsec_rx_sa __rcu *ptr)
154154
return sa;
155155
}
156156

157-
static struct macsec_rx_sa *macsec_active_rxsa_get(struct macsec_rx_sc *rx_sc)
158-
{
159-
struct macsec_rx_sa *sa = NULL;
160-
int an;
161-
162-
for (an = 0; an < MACSEC_NUM_AN; an++) {
163-
sa = macsec_rxsa_get(rx_sc->sa[an]);
164-
if (sa)
165-
break;
166-
}
167-
return sa;
168-
}
169-
170157
static void free_rx_sc_rcu(struct rcu_head *head)
171158
{
172159
struct macsec_rx_sc *rx_sc = container_of(head, struct macsec_rx_sc, rcu_head);
@@ -1208,15 +1195,12 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
12081195
/* If validateFrames is Strict or the C bit in the
12091196
* SecTAG is set, discard
12101197
*/
1211-
struct macsec_rx_sa *active_rx_sa = macsec_active_rxsa_get(rx_sc);
12121198
if (hdr->tci_an & MACSEC_TCI_C ||
12131199
secy->validate_frames == MACSEC_VALIDATE_STRICT) {
12141200
u64_stats_update_begin(&rxsc_stats->syncp);
12151201
rxsc_stats->stats.InPktsNotUsingSA++;
12161202
u64_stats_update_end(&rxsc_stats->syncp);
12171203
DEV_STATS_INC(secy->netdev, rx_errors);
1218-
if (active_rx_sa)
1219-
this_cpu_inc(active_rx_sa->stats->InPktsNotUsingSA);
12201204
goto drop_nosa;
12211205
}
12221206

@@ -1226,8 +1210,6 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
12261210
u64_stats_update_begin(&rxsc_stats->syncp);
12271211
rxsc_stats->stats.InPktsUnusedSA++;
12281212
u64_stats_update_end(&rxsc_stats->syncp);
1229-
if (active_rx_sa)
1230-
this_cpu_inc(active_rx_sa->stats->InPktsUnusedSA);
12311213
goto deliver;
12321214
}
12331215

0 commit comments

Comments
 (0)