batadv_interface_rx pskb_may_pull cleanup
Sven Eckelmann
maintainercover batadv_interface_rx pskb_may_pull cleanup
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
Sven Eckelmann
maintainerPATCH 1/3 batman-adv: Add kernel-doc for batadv_interface_rx
--- net/batman-adv/soft-interface.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
net/batman-adv/soft-interface.c +18 -0
@@ -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)
Signature · 1 line
2.7.0
Sven Eckelmann
maintainerPATCH 2/3 batman-adv: Remove unused parameter recv_if of batadv_interface_rx
In reply to Sven Eckelmann--- 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(-)
net/batman-adv/routing.c +2 -3
@@ -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 ;
net/batman-adv/soft-interface.c +2 -3
@@ -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);
net/batman-adv/soft-interface.h +2 -2
@@ -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);
Signature · 1 line
2.7.0
Sven Eckelmann
maintainerPATCH 3/3 batman-adv: Remove hdr_size skb size check in batadv_interface_rx
In reply to Sven EckelmannThe 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).
--- net/batman-adv/soft-interface.c | 4 ---- 1 file changed, 4 deletions(-)
net/batman-adv/soft-interface.c +0 -4
@@ -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);
Signature · 1 line
2.7.0
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: Add kernel-doc for batadv_interface_rx
In reply to Sven EckelmannQuoted 4 lines · On Sunday, February 28, 2016 11:38:50 Sven Eckelmann wrote:
Signed-off-by Sven Eckelmann <[email protected]>--- net/batman-adv/soft-interface.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
Applied in revision a90f291.
Thanks,
Marek
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 2/3] batman-adv: Remove unused parameter recv_if of batadv_interface_rx
In reply to Sven EckelmannQuoted 6 lines · On Sunday, February 28, 2016 11:38:51 Sven Eckelmann wrote:
Signed-off-by Sven Eckelmann <[email protected]>--- 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
Marek Lindner
AppliedRe: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: Remove hdr_size skb size check in batadv_interface_rx
In reply to Sven EckelmannQuoted 11 lines · On Sunday, February 28, 2016 11:38:52 Sven Eckelmann wrote:
The callers of
batadv_interface_rxhave 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 callingpskb_may_pullwithhdr_sizedirectly (batadv_recv_bcast_packet) or indirectly viabatadv_check_unicast_packet(batadv_recv_unicast_packet).Reported-by Marek Lindner <[email protected]>Signed-off-by Sven Eckelmann <[email protected]>--- net/batman-adv/soft-interface.c | 4 ---- 1 file changed, 4 deletions(-)
Applied in revision d1c596a.
Thanks,
Marek