Skip to content

Commit ca6d448

Browse files
shemmingerdavem330
authored andcommitted
bridge: avoid unnecessary read of jiffies
Jiffies is volatile so read it once. Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com> Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9bcdef3 commit ca6d448

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎net/bridge/br_fdb.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,15 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
592592
br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
593593
source->dev->name, addr, vid);
594594
} else {
595+
unsigned long now = jiffies;
596+
595597
/* fastpath: update of existing entry */
596598
if (unlikely(source != fdb->dst)) {
597599
fdb->dst = source;
598600
fdb_modified = true;
599601
}
600-
if (jiffies != fdb->updated)
601-
fdb->updated = jiffies;
602+
if (now != fdb->updated)
603+
fdb->updated = now;
602604
if (unlikely(added_by_user))
603605
fdb->added_by_user = 1;
604606
if (unlikely(fdb_modified))

‎net/bridge/br_input.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,13 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
195195
}
196196

197197
if (dst) {
198+
unsigned long now = jiffies;
199+
198200
if (dst->is_local)
199201
return br_pass_frame_up(skb);
200202

201-
if (jiffies != dst->used)
202-
dst->used = jiffies;
203+
if (now != dst->used)
204+
dst->used = now;
203205
br_forward(dst->dst, skb, local_rcv, false);
204206
} else {
205207
if (!mcast_hit)

0 commit comments

Comments
 (0)