public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 0/3] batadv_interface_rx pskb_may_pull cleanup
@ 2016-02-28 10:37 Sven Eckelmann
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Add kernel-doc for batadv_interface_rx Sven Eckelmann
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sven Eckelmann @ 2016-02-28 10:37 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 648 bytes --]

Hi,

this patchset is about cleaning up the pskb_may_pull(skb, hdr_size) in 
batadv_interface_rx. This was pointed out by Marek while he checked the 
"pskb_may_pull(skb, ETH_HLEN)"/"pskb_may_pull(skb, VLAN_ETH_HLEN)" fix [1]. 
This patchset *does not* replace the other fix.

The patchset contains three patches because:

 * first one is there to make clear that batadv_interface_rx is not
   responsible for checking hdr_size
 * second one is a bonus. Just noticed this useless parameter while writing
   the kernel-doc
 * the last patch then really removes this extra check.

Kind regards,
	Sven

[1] https://patchwork.open-mesh.org/patch/15853/

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Add kernel-doc for batadv_interface_rx
  2016-02-28 10:37 [B.A.T.M.A.N.] [PATCH 0/3] batadv_interface_rx pskb_may_pull cleanup Sven Eckelmann
@ 2016-02-28 10:38 ` Sven Eckelmann
  2016-03-20 10:00   ` Marek Lindner
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Remove unused parameter recv_if of batadv_interface_rx Sven Eckelmann
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Remove hdr_size skb size check in batadv_interface_rx Sven Eckelmann
  2 siblings, 1 reply; 7+ messages in thread
From: Sven Eckelmann @ 2016-02-28 10:38 UTC (permalink / raw)
  To: b.a.t.m.a.n

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/soft-interface.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 7679f3a..d786dce 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -381,6 +381,24 @@ end:
 	return NETDEV_TX_OK;
 }
 
+/**
+ * batadv_interface_rx - receive ethernet frame on local batman-adv interface
+ * @soft_iface: local interface which will receive the ethernet frame
+ * @skb: ethernet frame for @soft_iface
+ * @recv_if: interface on which the batman-adv packet was received
+ * @hdr_size: size of already parsed batman-adv header
+ * @orig_node: originator from which the batman-adv packet was sent
+ *
+ * Sends a ethernet frame to the receive path of the local @soft_iface.
+ * skb->data has still point to the batman-adv header with the size @hdr_size.
+ * The caller has to have parsed this header already and made sure that at least
+ * @hdr_size bytes are still available for pull in @skb.
+ *
+ * The packet may still get dropped. This can happen when the encapsulated
+ * ethernet frame is invalid or contains again an batman-adv packet. Also
+ * unicast packets will be dropped directly when it was sent between two
+ * isolated clients.
+ */
 void batadv_interface_rx(struct net_device *soft_iface,
 			 struct sk_buff *skb, struct batadv_hard_iface *recv_if,
 			 int hdr_size, struct batadv_orig_node *orig_node)
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Remove unused parameter recv_if of batadv_interface_rx
  2016-02-28 10:37 [B.A.T.M.A.N.] [PATCH 0/3] batadv_interface_rx pskb_may_pull cleanup Sven Eckelmann
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Add kernel-doc for batadv_interface_rx Sven Eckelmann
@ 2016-02-28 10:38 ` Sven Eckelmann
  2016-03-20 10:01   ` Marek Lindner
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Remove hdr_size skb size check in batadv_interface_rx Sven Eckelmann
  2 siblings, 1 reply; 7+ messages in thread
From: Sven Eckelmann @ 2016-02-28 10:38 UTC (permalink / raw)
  To: b.a.t.m.a.n

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/routing.c        | 5 ++---
 net/batman-adv/soft-interface.c | 5 ++---
 net/batman-adv/soft-interface.h | 4 ++--
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 45093c6..2008b8a 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -904,7 +904,7 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
 							hdr_size))
 			goto rx_success;
 
-		batadv_interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size,
+		batadv_interface_rx(recv_if->soft_iface, skb, hdr_size,
 				    orig_node);
 
 rx_success:
@@ -1114,8 +1114,7 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
 		goto rx_success;
 
 	/* broadcast for me */
-	batadv_interface_rx(recv_if->soft_iface, skb, recv_if, hdr_size,
-			    orig_node);
+	batadv_interface_rx(recv_if->soft_iface, skb, hdr_size, orig_node);
 
 rx_success:
 	ret = NET_RX_SUCCESS;
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index d786dce..bdda984 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -385,7 +385,6 @@ end:
  * batadv_interface_rx - receive ethernet frame on local batman-adv interface
  * @soft_iface: local interface which will receive the ethernet frame
  * @skb: ethernet frame for @soft_iface
- * @recv_if: interface on which the batman-adv packet was received
  * @hdr_size: size of already parsed batman-adv header
  * @orig_node: originator from which the batman-adv packet was sent
  *
@@ -400,8 +399,8 @@ end:
  * isolated clients.
  */
 void batadv_interface_rx(struct net_device *soft_iface,
-			 struct sk_buff *skb, struct batadv_hard_iface *recv_if,
-			 int hdr_size, struct batadv_orig_node *orig_node)
+			 struct sk_buff *skb, int hdr_size,
+			 struct batadv_orig_node *orig_node)
 {
 	struct batadv_bcast_packet *batadv_bcast_packet;
 	struct batadv_priv *bat_priv = netdev_priv(soft_iface);
diff --git a/net/batman-adv/soft-interface.h b/net/batman-adv/soft-interface.h
index 417d30a..15c2884 100644
--- a/net/batman-adv/soft-interface.h
+++ b/net/batman-adv/soft-interface.h
@@ -27,8 +27,8 @@ struct sk_buff;
 
 int batadv_skb_head_push(struct sk_buff *skb, unsigned int len);
 void batadv_interface_rx(struct net_device *soft_iface,
-			 struct sk_buff *skb, struct batadv_hard_iface *recv_if,
-			 int hdr_size, struct batadv_orig_node *orig_node);
+			 struct sk_buff *skb, int hdr_size,
+			 struct batadv_orig_node *orig_node);
 struct net_device *batadv_softif_create(const char *name);
 void batadv_softif_destroy_sysfs(struct net_device *soft_iface);
 bool batadv_softif_is_valid(const struct net_device *net_dev);
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Remove hdr_size skb size check in batadv_interface_rx
  2016-02-28 10:37 [B.A.T.M.A.N.] [PATCH 0/3] batadv_interface_rx pskb_may_pull cleanup Sven Eckelmann
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Add kernel-doc for batadv_interface_rx Sven Eckelmann
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Remove unused parameter recv_if of batadv_interface_rx Sven Eckelmann
@ 2016-02-28 10:38 ` Sven Eckelmann
  2016-03-20 10:01   ` Marek Lindner
  2 siblings, 1 reply; 7+ messages in thread
From: Sven Eckelmann @ 2016-02-28 10:38 UTC (permalink / raw)
  To: b.a.t.m.a.n

The callers of batadv_interface_rx have to make sure that enough data can
be pulled from the skb when they read the batman-adv header. The only two
functions using it are either calling pskb_may_pull with hdr_size directly
(batadv_recv_bcast_packet) or indirectly via batadv_check_unicast_packet
(batadv_recv_unicast_packet).

Reported-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/soft-interface.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index bdda984..f24dc59 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -413,10 +413,6 @@ void batadv_interface_rx(struct net_device *soft_iface,
 	batadv_bcast_packet = (struct batadv_bcast_packet *)skb->data;
 	is_bcast = (batadv_bcast_packet->packet_type == BATADV_BCAST);
 
-	/* check if enough space is available for pulling, and pull */
-	if (!pskb_may_pull(skb, hdr_size))
-		goto dropped;
-
 	skb_pull_rcsum(skb, hdr_size);
 	skb_reset_mac_header(skb);
 
-- 
2.7.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Add kernel-doc for batadv_interface_rx
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Add kernel-doc for batadv_interface_rx Sven Eckelmann
@ 2016-03-20 10:00   ` Marek Lindner
  0 siblings, 0 replies; 7+ messages in thread
From: Marek Lindner @ 2016-03-20 10:00 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 259 bytes --]

On Sunday, February 28, 2016 11:38:50 Sven Eckelmann wrote:
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
>  net/batman-adv/soft-interface.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

Applied in revision a90f291.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Remove unused parameter recv_if of batadv_interface_rx
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Remove unused parameter recv_if of batadv_interface_rx Sven Eckelmann
@ 2016-03-20 10:01   ` Marek Lindner
  0 siblings, 0 replies; 7+ messages in thread
From: Marek Lindner @ 2016-03-20 10:01 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 350 bytes --]

On Sunday, February 28, 2016 11:38:51 Sven Eckelmann wrote:
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
>  net/batman-adv/routing.c        | 5 ++---
>  net/batman-adv/soft-interface.c | 5 ++---
>  net/batman-adv/soft-interface.h | 4 ++--
>  3 files changed, 6 insertions(+), 8 deletions(-)

Applied in revision 4c0f1f6.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Remove hdr_size skb size check in batadv_interface_rx
  2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Remove hdr_size skb size check in batadv_interface_rx Sven Eckelmann
@ 2016-03-20 10:01   ` Marek Lindner
  0 siblings, 0 replies; 7+ messages in thread
From: Marek Lindner @ 2016-03-20 10:01 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 639 bytes --]

On Sunday, February 28, 2016 11:38:52 Sven Eckelmann wrote:
> The callers of batadv_interface_rx have to make sure that enough data can
> be pulled from the skb when they read the batman-adv header. The only two
> functions using it are either calling pskb_may_pull with hdr_size directly
> (batadv_recv_bcast_packet) or indirectly via batadv_check_unicast_packet
> (batadv_recv_unicast_packet).
> 
> Reported-by: Marek Lindner <mareklindner@neomailbox.ch>
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
>  net/batman-adv/soft-interface.c | 4 ----
>  1 file changed, 4 deletions(-)

Applied in revision d1c596a.

Thanks,
Marek

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-03-20 10:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-28 10:37 [B.A.T.M.A.N.] [PATCH 0/3] batadv_interface_rx pskb_may_pull cleanup Sven Eckelmann
2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Add kernel-doc for batadv_interface_rx Sven Eckelmann
2016-03-20 10:00   ` Marek Lindner
2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Remove unused parameter recv_if of batadv_interface_rx Sven Eckelmann
2016-03-20 10:01   ` Marek Lindner
2016-02-28 10:38 ` [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Remove hdr_size skb size check in batadv_interface_rx Sven Eckelmann
2016-03-20 10:01   ` Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox