Thread (7 messages) 7 messages, 2 authors, 2013-10-15

Re: [PATCH v4] net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)

From: David Miller <davem@davemloft.net>
Date: 2013-09-20 19:10:21

From: Arvid Brodin <redacted>
Date: Thu, 19 Sep 2013 03:11:58 +0200
+/* If dev is a HSR master, return 1; otherwise, return 0.
+ */
+bool is_hsr_master(struct net_device *dev)
Bool takes on either 'true' or 'false', not '1' or '0'.
+#if !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
+		/* We need to memmove the whole header to work around
+		 * alignment problems caused by the 6-byte HSR tag.
+		 */
+		memmove(skb_deliver->data - HSR_TAGLEN, skb_deliver->data,
+			skb_headlen(skb_deliver));
+		skb_deliver->data -= HSR_TAGLEN;
+		skb_deliver->tail -= HSR_TAGLEN;
+#endif
You can't do this.

First of all, you have no idea if subtracting skb->data a given amount
will underflow the skb buffer start.  You aren't even checking, all
of the standard skb_*() data adjustment interfaces do.

Secondly, everything after the header is now at the wrong offset from
the beginning of the packet.

You will have to memmove() the entire packet if you want to realign
where it starts.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help