]> git.droids-corp.org - dpdk.git/commitdiff
app/testpmd: swap MAC in IEEE1588 forwarding
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 10 Dec 2015 09:28:27 +0000 (09:28 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 10 Dec 2015 21:20:08 +0000 (22:20 +0100)
IEEE1588 forwarding mode uses same port to receive and transmit packets.
In this mode, the MAC address in the packets are not touched,
and therefore, packets could be sent with the same destination
MAC address as the MAC address of the port that is transmitting,
which causes the packet to be dropped in some NICs.

In order to avoid this scenario, MAC addresses are swapped
before packet is sent out.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
app/test-pmd/ieee1588fwd.c

index c69023afe760e2ee526403bb7542722f5b3d8ccb..0d3b37a7bfe37eacf845f387b22987e18b0addb9 100644 (file)
@@ -123,6 +123,7 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
 {
        struct rte_mbuf  *mb;
        struct ether_hdr *eth_hdr;
+       struct ether_addr addr;
        struct ptpv2_msg *ptp_hdr;
        uint16_t eth_type;
        uint32_t timesync_index;
@@ -205,6 +206,11 @@ ieee1588_packet_fwd(struct fwd_stream *fs)
        /* Read and check the RX timestamp. */
        port_ieee1588_rx_timestamp_check(fs->rx_port, timesync_index);
 
+       /* Swap dest and src mac addresses. */
+       ether_addr_copy(&eth_hdr->d_addr, &addr);
+       ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
+       ether_addr_copy(&addr, &eth_hdr->s_addr);
+
        /* Forward PTP packet with hardware TX timestamp */
        mb->ol_flags |= PKT_TX_IEEE1588_TMST;
        fs->tx_packets += 1;