ethernet: fix mac address increment error 28/37028/2
authorJieqiang Wang <jieqiang.wang@arm.com>
Sun, 14 Aug 2022 09:49:44 +0000 (17:49 +0800)
committerNeale Ranns <neale@graphiant.com>
Mon, 29 Aug 2022 23:55:08 +0000 (23:55 +0000)
Using "ip neighbor <ip-addr> <mac-addr> static count <count>" to add
static ARP entries will output wrong mac addresses due to lack of
big/little endian conversion. Fix this error by converting mac address
from big endian to little endian before doing the self-increment.

Before patched:

vpp# ip neighbor rdma-0 198.18.1.1 01:aa:bb:cc:dd:e0 static count 5
vpp# show ip neighbor
    Time                       IP                    Flags      Ethernet              Interface
      4.4400               198.18.1.5                  S    05:aa:bb:cc:dd:e0  rdma-0
      4.4399               198.18.1.4                  S    04:aa:bb:cc:dd:e0  rdma-0
      4.4399               198.18.1.3                  S    03:aa:bb:cc:dd:e0  rdma-0
      4.4399               198.18.1.2                  S    02:aa:bb:cc:dd:e0  rdma-0
      4.4399               198.18.1.1                  S    01:aa:bb:cc:dd:e0  rdma-0

After patched:

vpp# ip neighbor rdma-0 198.18.1.1 01:aa:bb:cc:dd:e0 static count 5
vpp# show ip neighbor
    Time                       IP                    Flags      Ethernet              Interface
      4.4528               198.18.1.5                  S    01:aa:bb:cc:dd:e4  rdma-0
      4.4528               198.18.1.4                  S    01:aa:bb:cc:dd:e3  rdma-0
      4.4528               198.18.1.3                  S    01:aa:bb:cc:dd:e2  rdma-0
      4.4527               198.18.1.2                  S    01:aa:bb:cc:dd:e1  rdma-0
      4.4527               198.18.1.1                  S    01:aa:bb:cc:dd:e0  rdma-0

Type: fix
Signed-off-by: Jieqiang Wang <jieqiang.wang@arm.com>
Change-Id: Iec1e00e381e4aba96639f831e7e42e070be3f278

src/vnet/ethernet/mac_address.c

index b798129..2237c37 100644 (file)
@@ -66,9 +66,9 @@ mac_address_increment (mac_address_t * mac)
 {
   u64 a;
 
-  a = mac_address_as_u64 (mac);
+  a = ethernet_mac_address_u64 (mac->bytes);
   a++;
-  mac_address_from_u64 (mac, a);
+  ethernet_mac_address_from_u64 (a, mac->bytes);
 }
 
 /*