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] alfred: Allow setting the source mac via unix sock
@ 2016-02-16 23:51 Dominik Heidler
  2016-02-17  8:10 ` Sven Eckelmann
  2016-02-17  8:39 ` Sven Eckelmann
  0 siblings, 2 replies; 5+ messages in thread
From: Dominik Heidler @ 2016-02-16 23:51 UTC (permalink / raw)
  To: b.a.t.m.a.n

The server will only overwrite the mac if it is zero.

Signed-off-by: Dominik Heidler <dominik@heidler.eu>
---

The alfred client sets the mac to zero by default
so this shouldn't break existing behaviour.


 unix_sock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/unix_sock.c b/unix_sock.c
index 3c7e583..12a10e6 100644
--- a/unix_sock.c
+++ b/unix_sock.c
@@ -119,7 +119,9 @@ static int unix_sock_add_data(struct globals *globals,
 
 	data = push->data;
 	data_len = ntohs(data->header.length);
-	memcpy(data->source, &interface->hwaddr, sizeof(interface->hwaddr));
+	static const char zero[ETH_ALEN] = { 0 };
+	if (!memcmp(zero, data->source, sizeof(data->source)))
+		memcpy(data->source, &interface->hwaddr, sizeof(interface->hwaddr));
 
 	if ((int)(data_len + sizeof(*data)) > len)
 		goto err;
-- 
2.7.0


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

* Re: [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock
  2016-02-16 23:51 [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock Dominik Heidler
@ 2016-02-17  8:10 ` Sven Eckelmann
  2016-02-17  8:39 ` Sven Eckelmann
  1 sibling, 0 replies; 5+ messages in thread
From: Sven Eckelmann @ 2016-02-17  8:10 UTC (permalink / raw)
  To: b.a.t.m.a.n

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

On Wednesday 17 February 2016 00:51:10 Dominik Heidler wrote:
> The server will only overwrite the mac if it is zero.
> 
> Signed-off-by: Dominik Heidler <dominik@heidler.eu>

I think this breaks the forwarding/synchronization rules of alfred.

@Simon, what do you say?

kind regards,
	Sven

> ---
> 
> The alfred client sets the mac to zero by default
> so this shouldn't break existing behaviour.
> 
> 
>  unix_sock.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/unix_sock.c b/unix_sock.c
> index 3c7e583..12a10e6 100644
> --- a/unix_sock.c
> +++ b/unix_sock.c
> @@ -119,7 +119,9 @@ static int unix_sock_add_data(struct globals *globals,
>  
>  	data = push->data;
>  	data_len = ntohs(data->header.length);
> -	memcpy(data->source, &interface->hwaddr, sizeof(interface->hwaddr));
> +	static const char zero[ETH_ALEN] = { 0 };
> +	if (!memcmp(zero, data->source, sizeof(data->source)))
> +		memcpy(data->source, &interface->hwaddr, sizeof(interface->hwaddr));
>  
>  	if ((int)(data_len + sizeof(*data)) > len)
>  		goto err;
> 

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

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

* Re: [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock
  2016-02-16 23:51 [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock Dominik Heidler
  2016-02-17  8:10 ` Sven Eckelmann
@ 2016-02-17  8:39 ` Sven Eckelmann
  2016-02-17 10:36   ` Dominik Heidler
  1 sibling, 1 reply; 5+ messages in thread
From: Sven Eckelmann @ 2016-02-17  8:39 UTC (permalink / raw)
  To: b.a.t.m.a.n

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

On Wednesday 17 February 2016 00:51:10 Dominik Heidler wrote:
> The alfred client sets the mac to zero by default
> so this shouldn't break existing behaviour.

This also may not to be true. Some users of alfred may not set the source in 
alfred_data and thus they may end up with random bytes when reusing a buffer, 
allocating a buffer without memset or using an uninitialized buffer on stack.

It is bad practice to send uninitialized bytes around but I just wanted to 
point out that potential problem.

Your patch also doesn't explain why this feature may be required.

Btw. you can grep for "data_source" to find the code related to the 
sync/forwarded rules of alfred.

Kind regards,
	Sven

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

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

* Re: [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock
  2016-02-17  8:39 ` Sven Eckelmann
@ 2016-02-17 10:36   ` Dominik Heidler
  2016-03-11 15:27     ` Simon Wunderlich
  0 siblings, 1 reply; 5+ messages in thread
From: Dominik Heidler @ 2016-02-17 10:36 UTC (permalink / raw)
  To: Sven Eckelmann, b.a.t.m.a.n

Am 17.02.2016 um 09:39 schrieb Sven Eckelmann:
> Your patch also doesn't explain why this feature may be required.

I'm running an alfred master server with this patch, so that I can run a script that will
inject data of legacy clients (that don't have an alfred slave, but need to be crawled).

Regards,
Dominik

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

* Re: [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock
  2016-02-17 10:36   ` Dominik Heidler
@ 2016-03-11 15:27     ` Simon Wunderlich
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Wunderlich @ 2016-03-11 15:27 UTC (permalink / raw)
  To: b.a.t.m.a.n

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

On Wednesday 17 February 2016 11:36:01 Dominik Heidler wrote:
> Am 17.02.2016 um 09:39 schrieb Sven Eckelmann:
> > Your patch also doesn't explain why this feature may be required.
> 
> I'm running an alfred master server with this patch, so that I can run a
> script that will inject data of legacy clients (that don't have an alfred
> slave, but need to be crawled).

Sorry for the late reply. In generally I think this change is acceptable, 
however I'd like to request the following changes and to resend your patch: 

 * Please write a proper commit message in the patch, explaining your scenario 
and why you need it
 * Write a comment above the change you made to explain that clients should 
set the mac to 00:00:00:00:00:00 by default, unless they want alfred to use 
its mac for them.

Thank you!
     Simon

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

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

end of thread, other threads:[~2016-03-11 15:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-16 23:51 [B.A.T.M.A.N.] [PATCH] alfred: Allow setting the source mac via unix sock Dominik Heidler
2016-02-17  8:10 ` Sven Eckelmann
2016-02-17  8:39 ` Sven Eckelmann
2016-02-17 10:36   ` Dominik Heidler
2016-03-11 15:27     ` Simon Wunderlich

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