mos-stack / mOS-networking-stack

A Specialized Network Programming Library for Stateful Middleboxes:
http://mos.kaist.edu
Other
103 stars 21 forks source link

Mac address prevent change? #18

Closed laybatin closed 6 years ago

laybatin commented 6 years ago

I am building and testing an in-line environment. Like this image(http://www.ndsl.kaist.edu/mos_guide/_images/midstat_inline.png) I'm running sample progam is midstat

mos.conf
#######################
# MOS-RELATED OPTIONS #
#######################
mos {
    forward = 1

    #######################
    ##### I/O OPTIONS #####
    #######################
    # number of memory channels per socket [mandatory for DPDK]
    nb_mem_channels = 2

    # devices used for MOS applications [mandatory]
    netdev {
        dpdk0 0x0001
        dpdk1 0x0001
    }

    #######################
    ### LOGGING OPTIONS ###
    #######################
    # NICs to print network statistics per second
    # if enabled, mTCP will print xx Gbps and xx pps for RX and TX
    stat_print = dpdk0 dpdk1

    # A directory contains MOS system log files
    mos_log = logs/

    ########################
    ## NETWORK PARAMETERS ##
    ########################
    # This to configure static arp table
    # (Destination IP address) (Destination MAC address)
    arp_table {
    }

    # This is to configure static routing table
    # (Destination address)/(Prefix) (Device name)
    route_table {
    }

    # This is to configure static bump-in-the-wire NIC forwarding table
    # DEVNIC_A DEVNIC_B ## (e.g. dpdk0 dpdk1) 
    nic_forward_table {
      dpdk0 dpdk1
    }
}
Client(00:00:00:00:00:01) - Server(00:00:00:00:00:02)
root@Server:/tcpdump host 192.168.100.233 -en
00:00:00:00:e0:01 > 00:00:00:00:00:02, ethertype IPv4 (0x0800), length...

Client(00:00:00:00:00:01) - dpdk0(00:90:fb:45:d9:1d) - dpdk1(00:90:fb:45:d9:1e) - Server(00:00:00:00:00:02)
root@Server:/tcpdump host 192.168.100.233 -en
00:90:fb:45:d9:1e > 00:00:00:00:00:02, ethertype IPv4 (0x0800), length...

Is it possible to maintain MAC Address in an Inline configuration environment?

Client MAC Address is replaced with the MAC Address of the host Can you prevent replace?

ajamshed commented 6 years ago

Hi @laybatin,

I am sorry for the delayed response. Unfortunately we don't have any API function that allows mOS application developer to prevent src MAC address change. However, you can easily retain the MAC address if you can change the logic within the mOS core stack. Function EthernetOutput() is where the source MAC address is overwritten. You can use pctx->p.ethh->h_source[i] instead of dst_haddr so that you can retain the source MAC address. Let me know if you still see any issues. I can then try to test out this change in my own testbed.

laybatin commented 6 years ago

It's very nice Thank you