diff mbox

[PATCHv3,1/1] validation: pktio: fix invalid mac addr

Message ID 1483623566-17460-1-git-send-email-bala.manoharan@linaro.org
State Accepted
Commit 47b343a8f508b1dad511a1498999caa876c12eb5
Headers show

Commit Message

Balasubramanian Manoharan Jan. 5, 2017, 1:39 p.m. UTC
Fixes https://bugs.linaro.org/show_bug.cgi?id=2496

Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

---
v3: Review comment incorporation

 test/common_plat/validation/api/pktio/pktio.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

-- 
1.9.1

Comments

Josep Puigdemont Jan. 9, 2017, 2:53 p.m. UTC | #1
On Thu, Jan 05, 2017 at 07:09:26PM +0530, Balasubramanian Manoharan wrote:
> Fixes https://bugs.linaro.org/show_bug.cgi?id=2496

> 

> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

> ---

> v3: Review comment incorporation

> 

>  test/common_plat/validation/api/pktio/pktio.c | 9 ++++++---

>  1 file changed, 6 insertions(+), 3 deletions(-)

> 

> diff --git a/test/common_plat/validation/api/pktio/pktio.c b/test/common_plat/validation/api/pktio/pktio.c

> index 7c979fb..438b7e8 100644

> --- a/test/common_plat/validation/api/pktio/pktio.c

> +++ b/test/common_plat/validation/api/pktio/pktio.c

> @@ -31,6 +31,8 @@

>  #define PKTIN_TS_MAX_RES       10000000000

>  #define PKTIN_TS_CMP_RES       1

>  

> +#define PKTIO_SRC_MAC		{1, 2, 3, 4, 5, 6}

> +#define PKTIO_DST_MAC		{6, 5, 4, 3, 2, 1}

>  #undef DEBUG_STATS

>  

>  /** interface names used for testing */

> @@ -245,7 +247,8 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)

>  	odph_udphdr_t *udp;

>  	char *buf;

>  	uint16_t seq;

> -	uint8_t mac[ODP_PKTIO_MACADDR_MAXSIZE] = {0};

> +	uint8_t src_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_SRC_MAC;

> +	uint8_t dst_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_DST_MAC;

>  	int pkt_len = odp_packet_len(pkt);

>  

>  	buf = odp_packet_data(pkt);

> @@ -253,8 +256,8 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)

>  	/* Ethernet */

>  	odp_packet_l2_offset_set(pkt, 0);

>  	eth = (odph_ethhdr_t *)buf;

> -	memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);

> -	memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);

> +	memcpy(eth->src.addr, &src_mac, ODPH_ETHADDR_LEN);

> +	memcpy(eth->dst.addr, &dst_mac, ODPH_ETHADDR_LEN);


I'd prefer to have src_mac and dst_mac (without &), but this works too.

Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>


/Josep
>  	eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);

>  

>  	/* IP */

> -- 

> 1.9.1

>
Maxim Uvarov Jan. 10, 2017, 2:54 p.m. UTC | #2
Merged with dropping & as discussed.

Maxim.

On 01/09/17 17:53, Josep Puigdemont wrote:
> On Thu, Jan 05, 2017 at 07:09:26PM +0530, Balasubramanian Manoharan wrote:

>> Fixes https://bugs.linaro.org/show_bug.cgi?id=2496

>>

>> Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>

>> ---

>> v3: Review comment incorporation

>>

>>  test/common_plat/validation/api/pktio/pktio.c | 9 ++++++---

>>  1 file changed, 6 insertions(+), 3 deletions(-)

>>

>> diff --git a/test/common_plat/validation/api/pktio/pktio.c b/test/common_plat/validation/api/pktio/pktio.c

>> index 7c979fb..438b7e8 100644

>> --- a/test/common_plat/validation/api/pktio/pktio.c

>> +++ b/test/common_plat/validation/api/pktio/pktio.c

>> @@ -31,6 +31,8 @@

>>  #define PKTIN_TS_MAX_RES       10000000000

>>  #define PKTIN_TS_CMP_RES       1

>>  

>> +#define PKTIO_SRC_MAC		{1, 2, 3, 4, 5, 6}

>> +#define PKTIO_DST_MAC		{6, 5, 4, 3, 2, 1}

>>  #undef DEBUG_STATS

>>  

>>  /** interface names used for testing */

>> @@ -245,7 +247,8 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)

>>  	odph_udphdr_t *udp;

>>  	char *buf;

>>  	uint16_t seq;

>> -	uint8_t mac[ODP_PKTIO_MACADDR_MAXSIZE] = {0};

>> +	uint8_t src_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_SRC_MAC;

>> +	uint8_t dst_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_DST_MAC;

>>  	int pkt_len = odp_packet_len(pkt);

>>  

>>  	buf = odp_packet_data(pkt);

>> @@ -253,8 +256,8 @@ static uint32_t pktio_init_packet(odp_packet_t pkt)

>>  	/* Ethernet */

>>  	odp_packet_l2_offset_set(pkt, 0);

>>  	eth = (odph_ethhdr_t *)buf;

>> -	memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);

>> -	memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);

>> +	memcpy(eth->src.addr, &src_mac, ODPH_ETHADDR_LEN);

>> +	memcpy(eth->dst.addr, &dst_mac, ODPH_ETHADDR_LEN);

> 

> I'd prefer to have src_mac and dst_mac (without &), but this works too.

> 

> Reviewed-by: Josep Puigdemont <josep.puigdemont@linaro.org>

> 

> /Josep

>>  	eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);

>>  

>>  	/* IP */

>> -- 

>> 1.9.1

>>
diff mbox

Patch

diff --git a/test/common_plat/validation/api/pktio/pktio.c b/test/common_plat/validation/api/pktio/pktio.c
index 7c979fb..438b7e8 100644
--- a/test/common_plat/validation/api/pktio/pktio.c
+++ b/test/common_plat/validation/api/pktio/pktio.c
@@ -31,6 +31,8 @@ 
 #define PKTIN_TS_MAX_RES       10000000000
 #define PKTIN_TS_CMP_RES       1
 
+#define PKTIO_SRC_MAC		{1, 2, 3, 4, 5, 6}
+#define PKTIO_DST_MAC		{6, 5, 4, 3, 2, 1}
 #undef DEBUG_STATS
 
 /** interface names used for testing */
@@ -245,7 +247,8 @@  static uint32_t pktio_init_packet(odp_packet_t pkt)
 	odph_udphdr_t *udp;
 	char *buf;
 	uint16_t seq;
-	uint8_t mac[ODP_PKTIO_MACADDR_MAXSIZE] = {0};
+	uint8_t src_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_SRC_MAC;
+	uint8_t dst_mac[ODP_PKTIO_MACADDR_MAXSIZE] = PKTIO_DST_MAC;
 	int pkt_len = odp_packet_len(pkt);
 
 	buf = odp_packet_data(pkt);
@@ -253,8 +256,8 @@  static uint32_t pktio_init_packet(odp_packet_t pkt)
 	/* Ethernet */
 	odp_packet_l2_offset_set(pkt, 0);
 	eth = (odph_ethhdr_t *)buf;
-	memcpy(eth->src.addr, mac, ODPH_ETHADDR_LEN);
-	memcpy(eth->dst.addr, mac, ODPH_ETHADDR_LEN);
+	memcpy(eth->src.addr, &src_mac, ODPH_ETHADDR_LEN);
+	memcpy(eth->dst.addr, &dst_mac, ODPH_ETHADDR_LEN);
 	eth->type = odp_cpu_to_be_16(ODPH_ETHTYPE_IPV4);
 
 	/* IP */