* [PATCH net-next] can: rework skb reserved data handling
@ 2013-01-28 18:33 Oliver Hartkopp
2013-01-28 23:17 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Hartkopp @ 2013-01-28 18:33 UTC (permalink / raw)
To: David Miller; +Cc: Marc Kleine-Budde, Linux Netdev List
Added accessor and skb_reserve helpers for struct can_skb_priv.
Removed pointless skb_headroom() check.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
CC: Marc Kleine-Budde <mkl@pengutronix.de>
---
Hello Dave,
as suggested here's a rework fixing the two issues with the new CAN skb
private data space.
It looks really much better now. Tnx for the feedback.
Oliver
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 59ada08..f9cba41 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -512,8 +512,8 @@ struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
skb->pkt_type = PACKET_BROADCAST;
skb->ip_summed = CHECKSUM_UNNECESSARY;
- skb_reserve(skb, sizeof(struct can_skb_priv));
- ((struct can_skb_priv *)(skb->head))->ifindex = dev->ifindex;
+ can_skb_reserve(skb);
+ can_skb_prv(skb)->ifindex = dev->ifindex;
*cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
memset(*cf, 0, sizeof(struct can_frame));
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
index e79a8d1..06b7e09 100644
--- a/drivers/net/can/slcan.c
+++ b/drivers/net/can/slcan.c
@@ -195,8 +195,8 @@ static void slc_bump(struct slcan *sl)
skb->pkt_type = PACKET_BROADCAST;
skb->ip_summed = CHECKSUM_UNNECESSARY;
- skb_reserve(skb, sizeof(struct can_skb_priv));
- ((struct can_skb_priv *)(skb->head))->ifindex = sl->dev->ifindex;
+ can_skb_reserve(skb);
+ can_skb_prv(skb)->ifindex = sl->dev->ifindex;
memcpy(skb_put(skb, sizeof(struct can_frame)),
&cf, sizeof(struct can_frame));
diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h
index 4b0f24d..2f0543f 100644
--- a/include/linux/can/skb.h
+++ b/include/linux/can/skb.h
@@ -32,4 +32,14 @@ struct can_skb_priv {
struct can_frame cf[0];
};
+static inline struct can_skb_priv *can_skb_prv(struct sk_buff *skb)
+{
+ return (struct can_skb_priv *)(skb->head);
+}
+
+static inline void can_skb_reserve(struct sk_buff *skb)
+{
+ skb_reserve(skb, sizeof(struct can_skb_priv));
+}
+
#endif /* CAN_SKB_H */
diff --git a/net/can/bcm.c b/net/can/bcm.c
index ccc27b9..28e12d1 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -261,8 +261,8 @@ static void bcm_can_tx(struct bcm_op *op)
if (!skb)
goto out;
- skb_reserve(skb, sizeof(struct can_skb_priv));
- ((struct can_skb_priv *)(skb->head))->ifindex = dev->ifindex;
+ can_skb_reserve(skb);
+ can_skb_prv(skb)->ifindex = dev->ifindex;
memcpy(skb_put(skb, CFSIZ), cf, CFSIZ);
@@ -1207,7 +1207,7 @@ static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk)
if (!skb)
return -ENOMEM;
- skb_reserve(skb, sizeof(struct can_skb_priv));
+ can_skb_reserve(skb);
err = memcpy_fromiovec(skb_put(skb, CFSIZ), msg->msg_iov, CFSIZ);
if (err < 0) {
@@ -1221,7 +1221,7 @@ static int bcm_tx_send(struct msghdr *msg, int ifindex, struct sock *sk)
return -ENODEV;
}
- ((struct can_skb_priv *)(skb->head))->ifindex = dev->ifindex;
+ can_skb_prv(skb)->ifindex = dev->ifindex;
skb->dev = dev;
skb->sk = sk;
err = can_send(skb, 1); /* send with loopback */
diff --git a/net/can/gw.c b/net/can/gw.c
index acdd465..c185fcd 100644
--- a/net/can/gw.c
+++ b/net/can/gw.c
@@ -381,9 +381,7 @@ static void can_can_gw_rcv(struct sk_buff *skb, void *data)
/* is sending the skb back to the incoming interface not allowed? */
if (!(gwj->flags & CGW_FLAGS_CAN_IIF_TX_OK) &&
- skb_headroom(skb) == sizeof(struct can_skb_priv) &&
- (((struct can_skb_priv *)(skb->head))->ifindex ==
- gwj->dst.dev->ifindex))
+ can_skb_prv(skb)->ifindex == gwj->dst.dev->ifindex)
return;
/*
diff --git a/net/can/raw.c b/net/can/raw.c
index 5d860e8..c1764e4 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -705,8 +705,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct socket *sock,
if (!skb)
goto put_dev;
- skb_reserve(skb, sizeof(struct can_skb_priv));
- ((struct can_skb_priv *)(skb->head))->ifindex = dev->ifindex;
+ can_skb_reserve(skb);
+ can_skb_prv(skb)->ifindex = dev->ifindex;
err = memcpy_fromiovec(skb_put(skb, size), msg->msg_iov, size);
if (err < 0)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] can: rework skb reserved data handling
2013-01-28 18:33 [PATCH net-next] can: rework skb reserved data handling Oliver Hartkopp
@ 2013-01-28 23:17 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-01-28 23:17 UTC (permalink / raw)
To: socketcan; +Cc: mkl, netdev
From: Oliver Hartkopp <socketcan@hartkopp.net>
Date: Mon, 28 Jan 2013 19:33:33 +0100
> Added accessor and skb_reserve helpers for struct can_skb_priv.
> Removed pointless skb_headroom() check.
>
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> CC: Marc Kleine-Budde <mkl@pengutronix.de>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-28 23:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-28 18:33 [PATCH net-next] can: rework skb reserved data handling Oliver Hartkopp
2013-01-28 23:17 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).