Skip to contentSkip to conversation

: ROUTE: convert hh_lock to seqlock

PATCH Applied Robert Edmonds 2 participants 2 messages May 24, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : ROUTE: convert hh_lock to seqlock

hh_cache's lock has been converted to a seqlock in recent kernels.

---
 ipv4/netfilter/ipt_ROUTE.c  |   19 +++++++++++--------
 ipv6/netfilter/ip6t_ROUTE.c |    8 +++++---
 2 files changed, 16 insertions(+), 11 deletions(-)
net/ipv4/netfilter/ipt_ROUTE.c +7 -5
diff -urNad netfilter-extensions-20070520+debian~/net/ipv4/netfilter/ipt_ROUTE.c netfilter-extensions-20070520+debian/net/ipv4/netfilter/ipt_ROUTE.c
@@ -118,6 +118,7 @@
 	struct hh_cache *hh = dst->hh;
 	struct net_device *dev = dst->dev;
 	int hh_len = LL_RESERVED_SPACE(dev);
+	unsigned seq;
 
 	/* Be paranoid, rather than too clever. */
 	if (unlikely(skb_headroom(skb) < hh_len && dev->hard_header)) {
@@ -135,12 +136,13 @@
 	}
 
 	if (hh) {
-		int hh_alen;
+		do {
+			int hh_alen;
 
-		read_lock_bh(&hh->hh_lock);
-		hh_alen = HH_DATA_ALIGN(hh->hh_len);
-  		memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
-		read_unlock_bh(&hh->hh_lock);
+			seq = read_seqbegin(&hh->hh_lock);
+			hh_alen = HH_DATA_ALIGN(hh->hh_len);
+			memcpy(skb->data - hh_alen, hh->hh_data, hh_alen);
+		} while (read_seqretry(&hh->hh_lock, seq));
 		skb_push(skb, hh->hh_len);
 		hh->hh_output(skb);
 	} else if (dst->neighbour)
net/ipv6/netfilter/ip6t_ROUTE.c +5 -3
diff -urNad netfilter-extensions-20070520+debian~/net/ipv6/netfilter/ip6t_ROUTE.c netfilter-extensions-20070520+debian/net/ipv6/netfilter/ip6t_ROUTE.c
@@ -120,11 +120,13 @@
 {
 	struct dst_entry *dst = skb->dst;
 	struct hh_cache *hh = dst->hh;
+	unsigned seq;
 
 	if (hh) {
-		read_lock_bh(&hh->hh_lock);
-		memcpy(skb->data - 16, hh->hh_data, 16);
-		read_unlock_bh(&hh->hh_lock);
+		do {
+			seq = read_seqbegin(&hh->hh_lock);
+			memcpy(skb->data - 16, hh->hh_data, 16);
+		} while (read_seqretry(&hh->hh_lock, seq));
 		skb_push(skb, hh->hh_len);
 		hh->hh_output(skb);
 	} else if (dst->neighbour)
#1 lore raw
Quoted 1 line · Robert Edmonds

hh_cache's lock has been converted to a seqlock in recent kernels.

Applied, thanks. I wish someone else could take care of ROUTE maintenance.