* [B.A.T.M.A.N.] [PATCH] batman-adv: use check_unicast_packet() in recv_roam_adv()
@ 2012-07-29 22:50 Antonio Quartulli
2012-07-30 7:56 ` Marek Lindner
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Antonio Quartulli @ 2012-07-29 22:50 UTC (permalink / raw)
To: b.a.t.m.a.n
To avoid code duplication and simplify later changes, check_unicast_packet() is
now used into recv_roam_adv() instead of letting it perform all the checks by
itself
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
routing.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/routing.c b/routing.c
index 939fc01..7ebd922 100644
--- a/routing.c
+++ b/routing.c
@@ -687,21 +687,9 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_roam_adv_packet *roam_adv_packet;
struct batadv_orig_node *orig_node;
- struct ethhdr *ethhdr;
-
- /* drop packet if it has not necessary minimum size */
- if (unlikely(!pskb_may_pull(skb,
- sizeof(struct batadv_roam_adv_packet))))
- goto out;
+ int hdr_size = sizeof(struct batadv_roam_adv_packet);
- ethhdr = (struct ethhdr *)skb_mac_header(skb);
-
- /* packet with unicast indication but broadcast recipient */
- if (is_broadcast_ether_addr(ethhdr->h_dest))
- goto out;
-
- /* packet with broadcast sender address */
- if (is_broadcast_ether_addr(ethhdr->h_source))
+ if (batadv_check_unicast_packet(skb, hdr_size) < 0)
goto out;
batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX);
--
1.7.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: use check_unicast_packet() in recv_roam_adv()
2012-07-29 22:50 [B.A.T.M.A.N.] [PATCH] batman-adv: use check_unicast_packet() in recv_roam_adv() Antonio Quartulli
@ 2012-07-30 7:56 ` Marek Lindner
2012-07-30 9:20 ` Antonio Quartulli
2012-07-31 12:12 ` [B.A.T.M.A.N.] [PATCHv2] " Antonio Quartulli
2012-07-31 15:19 ` [B.A.T.M.A.N.] [PATCHv3] " Antonio Quartulli
2 siblings, 1 reply; 6+ messages in thread
From: Marek Lindner @ 2012-07-30 7:56 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
On Monday, July 30, 2012 00:50:03 Antonio Quartulli wrote:
> @@ -687,21 +687,9 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct
> batadv_hard_iface *recv_if) struct batadv_priv *bat_priv =
> netdev_priv(recv_if->soft_iface); struct batadv_roam_adv_packet
> *roam_adv_packet;
> struct batadv_orig_node *orig_node;
> - struct ethhdr *ethhdr;
> -
> - /* drop packet if it has not necessary minimum size */
> - if (unlikely(!pskb_may_pull(skb,
> - sizeof(struct batadv_roam_adv_packet))))
> - goto out;
> + int hdr_size = sizeof(struct batadv_roam_adv_packet);
Shouldn't we do: int hdr_size = sizeof(*roam_adv_packet); ?
Regards,
Marek
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: use check_unicast_packet() in recv_roam_adv()
2012-07-30 7:56 ` Marek Lindner
@ 2012-07-30 9:20 ` Antonio Quartulli
0 siblings, 0 replies; 6+ messages in thread
From: Antonio Quartulli @ 2012-07-30 9:20 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
[-- Attachment #1: Type: text/plain, Size: 950 bytes --]
On Mon, Jul 30, 2012 at 09:56:51AM +0200, Marek Lindner wrote:
> On Monday, July 30, 2012 00:50:03 Antonio Quartulli wrote:
> > @@ -687,21 +687,9 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct
> > batadv_hard_iface *recv_if) struct batadv_priv *bat_priv =
> > netdev_priv(recv_if->soft_iface); struct batadv_roam_adv_packet
> > *roam_adv_packet;
> > struct batadv_orig_node *orig_node;
> > - struct ethhdr *ethhdr;
> > -
> > - /* drop packet if it has not necessary minimum size */
> > - if (unlikely(!pskb_may_pull(skb,
> > - sizeof(struct batadv_roam_adv_packet))))
> > - goto out;
> > + int hdr_size = sizeof(struct batadv_roam_adv_packet);
>
> Shouldn't we do: int hdr_size = sizeof(*roam_adv_packet); ?
right. I copy/pasted the old code and I forgot to change it.
Will fix.
Thanks
>
>
> Regards,
> Marek
--
Antonio Quartulli
..each of us alone is worth nothing..
Ernesto "Che" Guevara
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [B.A.T.M.A.N.] [PATCHv2] batman-adv: use check_unicast_packet() in recv_roam_adv()
2012-07-29 22:50 [B.A.T.M.A.N.] [PATCH] batman-adv: use check_unicast_packet() in recv_roam_adv() Antonio Quartulli
2012-07-30 7:56 ` Marek Lindner
@ 2012-07-31 12:12 ` Antonio Quartulli
2012-07-31 15:19 ` [B.A.T.M.A.N.] [PATCHv3] " Antonio Quartulli
2 siblings, 0 replies; 6+ messages in thread
From: Antonio Quartulli @ 2012-07-31 12:12 UTC (permalink / raw)
To: b.a.t.m.a.n
To avoid code duplication and to simplify further changes,
check_unicast_packet() is now used in recv_roam_adv() to check for not
well formed packets and so discard them.
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
v2:
commit message rearranged
routing.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/routing.c b/routing.c
index 939fc01..7ebd922 100644
--- a/routing.c
+++ b/routing.c
@@ -687,21 +687,9 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_roam_adv_packet *roam_adv_packet;
struct batadv_orig_node *orig_node;
- struct ethhdr *ethhdr;
-
- /* drop packet if it has not necessary minimum size */
- if (unlikely(!pskb_may_pull(skb,
- sizeof(struct batadv_roam_adv_packet))))
- goto out;
+ int hdr_size = sizeof(struct batadv_roam_adv_packet);
- ethhdr = (struct ethhdr *)skb_mac_header(skb);
-
- /* packet with unicast indication but broadcast recipient */
- if (is_broadcast_ether_addr(ethhdr->h_dest))
- goto out;
-
- /* packet with broadcast sender address */
- if (is_broadcast_ether_addr(ethhdr->h_source))
+ if (batadv_check_unicast_packet(skb, hdr_size) < 0)
goto out;
batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX);
--
1.7.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [B.A.T.M.A.N.] [PATCHv3] batman-adv: use check_unicast_packet() in recv_roam_adv()
2012-07-29 22:50 [B.A.T.M.A.N.] [PATCH] batman-adv: use check_unicast_packet() in recv_roam_adv() Antonio Quartulli
2012-07-30 7:56 ` Marek Lindner
2012-07-31 12:12 ` [B.A.T.M.A.N.] [PATCHv2] " Antonio Quartulli
@ 2012-07-31 15:19 ` Antonio Quartulli
2012-08-21 23:36 ` Marek Lindner
2 siblings, 1 reply; 6+ messages in thread
From: Antonio Quartulli @ 2012-07-31 15:19 UTC (permalink / raw)
To: b.a.t.m.a.n
To avoid code duplication and to simplify further changes,
check_unicast_packet() is now used in recv_roam_adv() to check for not
well formed packets and so discard them.
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
v2
- coment rearrangement
v3
- fixed sizeof argument (use the variable name instead of the type, if possible)
routing.c | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/routing.c b/routing.c
index 939fc01..e7a4e25 100644
--- a/routing.c
+++ b/routing.c
@@ -687,21 +687,8 @@ int batadv_recv_roam_adv(struct sk_buff *skb, struct batadv_hard_iface *recv_if)
struct batadv_priv *bat_priv = netdev_priv(recv_if->soft_iface);
struct batadv_roam_adv_packet *roam_adv_packet;
struct batadv_orig_node *orig_node;
- struct ethhdr *ethhdr;
-
- /* drop packet if it has not necessary minimum size */
- if (unlikely(!pskb_may_pull(skb,
- sizeof(struct batadv_roam_adv_packet))))
- goto out;
-
- ethhdr = (struct ethhdr *)skb_mac_header(skb);
- /* packet with unicast indication but broadcast recipient */
- if (is_broadcast_ether_addr(ethhdr->h_dest))
- goto out;
-
- /* packet with broadcast sender address */
- if (is_broadcast_ether_addr(ethhdr->h_source))
+ if (batadv_check_unicast_packet(skb, sizeof(*roam_adv_packet)) < 0)
goto out;
batadv_inc_counter(bat_priv, BATADV_CNT_TT_ROAM_ADV_RX);
--
1.7.9.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv3] batman-adv: use check_unicast_packet() in recv_roam_adv()
2012-07-31 15:19 ` [B.A.T.M.A.N.] [PATCHv3] " Antonio Quartulli
@ 2012-08-21 23:36 ` Marek Lindner
0 siblings, 0 replies; 6+ messages in thread
From: Marek Lindner @ 2012-08-21 23:36 UTC (permalink / raw)
To: The list for a Better Approach To Mobile Ad-hoc Networking
On Tuesday, July 31, 2012 17:19:15 Antonio Quartulli wrote:
> To avoid code duplication and to simplify further changes,
> check_unicast_packet() is now used in recv_roam_adv() to check for not
> well formed packets and so discard them.
>
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> ---
>
> v2
> - coment rearrangement
> v3
> - fixed sizeof argument (use the variable name instead of the type, if
> possible)
>
> routing.c | 15 +--------------
> 1 file changed, 1 insertion(+), 14 deletions(-)
Applied in revision 2ce4b9b.
Thanks,
Marek
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-08-21 23:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-29 22:50 [B.A.T.M.A.N.] [PATCH] batman-adv: use check_unicast_packet() in recv_roam_adv() Antonio Quartulli
2012-07-30 7:56 ` Marek Lindner
2012-07-30 9:20 ` Antonio Quartulli
2012-07-31 12:12 ` [B.A.T.M.A.N.] [PATCHv2] " Antonio Quartulli
2012-07-31 15:19 ` [B.A.T.M.A.N.] [PATCHv3] " Antonio Quartulli
2012-08-21 23:36 ` Marek Lindner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.