F-Stack / f-stack

F-Stack is an user space network development kit with high performance based on DPDK, FreeBSD TCP/IP stack and coroutine API.
http://www.f-stack.org
Other
3.82k stars 891 forks source link

Unable to establish communication with the assigned IP #784

Open ashish4u125 opened 1 year ago

ashish4u125 commented 1 year ago

I am totally new to f-stack. I am facing challenges in configuring IP addresses for my server machine's NICs. My goal is to efficiently receive packets from a switch,which is connected to a server machine having 3 NIC card(intel) of interface name eno1, eno2, ens1f0 and ens1f1 from which eno1 is connected to switch and I have binded eno1 to the dpdk.

To receive this package, I installed f-stack which is mentioned on your github repository, edited the 'config.ini' file, and i have assigned an IP addr , netmask, broadcast and gateway ,I have also enable the KNI in the config.ini and successfully compiled the f-stack, and sample application example such as helloworld running successfully on the server machine. However, I am still unable to establish communication with the assigned IP, i.e. When I run the 'ping' command from another system for the assigned IP address, I receive a "Destination Host Unreachable" error.

Could you please provide guidance on correctly assigning the IP address within the f-stack to enable packet reception from the switch?

Thanks a lot in advance!

jfb8856606 commented 1 year ago

It's usually a configuration issue, you can show your config.inif and ff_ifconfig/ff_netstat -anr/ff_arp -a info, and pcap, etc.

ashish4u125 commented 1 year ago

sure, my config.ini is below:

[dpdk]
# Hexadecimal bitmask of cores to run on.
lcore_mask=1

# Number of memory channels.
channel=4

# Specify base virtual address to map.
#base_virtaddr=0x7f0000000000

# Promiscuous mode of nic, defualt: enabled.
promiscuous=1
numa_on=1

# TX checksum offload skip, default: disabled.
# We need this switch enabled in the following cases:
# -> The application want to enforce wrong checksum for testing purposes
# -> Some cards advertize the offload capability. However, doesn't calculate checksum.
tx_csum_offoad_skip=0

# TCP segment offload, default: disabled.
tso=0

# HW vlan strip, default: enabled.
vlan_strip=1

# sleep when no pkts incomming
# unit: microseconds
idle_sleep=0

# sent packet delay time(0-100) while send less than 32 pkts.
# default 100 us.
# if set 0, means send pkts immediately.
# if set >100, will dealy 100 us.
# unit: microseconds
pkt_tx_delay=100

# use symmetric Receive-side Scaling(RSS) key, default: disabled.
symmetric_rss=0

# PCI device enable list.
# And driver options
#allow=02:00.0
# for multiple PCI devices
#allow=02:00.0,03:00.0

# enabled port list
#
# EBNF grammar:
#
#    exp      ::= num_list {"," num_list}
#    num_list ::= <num> | <range>
#    range    ::= <num>"-"<num>
#    num      ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
#
# examples
#    0-3       ports 0, 1,2,3 are enabled
#    1-3,4,7   ports 1,2,3,4,7 are enabled
#
# If use bonding, shoule config the bonding port id in port_list
# and not config slave port id in port_list
# such as, port 0 and port 1 trank to a bonding port 2,
# should set `port_list=2` and config `[port2]` section

port_list=0

# Number of vdev.
nb_vdev=0

# Number of bond.
nb_bond=0

# log level for dpdk, optional
# log_level=0

# Each core write into own pcap file, which is open one time, close one time if enough.
# Support dump the first snaplen bytes of each packet.
# if pcap file is lager than savelen bytes, it will be closed and next file was dumped into.
[pcap]
enable=0
snaplen=96
savelen=16777216
savepath=.

# Port config section
# Correspond to dpdk.port_list's index: port0, port1...
[port0]
#addr=192.168.1.2
#netmask=255.255.255.0
#broadcast=192.168.1.255
#gateway=192.168.1.1

addr=xxx.xxx.144.xx6
netmask=255.255.255.0
broadcast=xxx.xxx.144.255
gateway=xxx.xxx.144.1

# set interface name, Optional parameter.
#if_name=eno7

# IPv6 net addr, Optional parameters.
#addr6=ff::02
#prefix_len=64
#gateway6=ff::01

# Multi virtual IPv4/IPv6 net addr, Optional parameters.
#       `vip_ifname`: default `f-stack-x`
#       `vip_addr`: Separated by semicolons, MAX number 64;
#                   Only support netmask 255.255.255.255, broadcast x.x.x.255 now, hard code in `ff_veth_setvaddr`.
#       `vip_addr6`: Separated by semicolons, MAX number 64.
#       `vip_prefix_len`: All addr6 use the same prefix now, default 64.
#vip_ifname=lo0
#vip_addr=192.168.1.3;192.168.1.4;192.168.1.5;192.168.1.6
#vip_addr6=ff::03;ff::04;ff::05;ff::06;ff::07
#vip_prefix_len=64

# lcore list used to handle this port
# the format is same as port_list
#lcore_list=0

# bonding slave port list used to handle this port
# need to config while this port is a bonding port
# the format is same as port_list
#slave_port_list=0,1

# Vdev config section
# orrespond to dpdk.nb_vdev's index: vdev0, vdev1...
#    iface : Shouldn't set always.
#    path : The vuser device path in container. Required.
#    queues : The max queues of vuser. Optional, default 1, greater or equal to the number of processes.
#    queue_size : Queue size.Optional, default 256.
#    mac : The mac address of vuser. Optional, default random, if vhost use phy NIC, it should be set to the phy NIC's mac.
#    cq : Optional, if queues = 1, default 0; if queues > 1 default 1.
#[vdev0]
##iface=/usr/local/var/run/openvswitch/vhost-user0
#path=/var/run/openvswitch/vhost-user0
#queues=1
#queue_size=256
#mac=00:00:00:00:00:01
#cq=0
# bond config section
# See http://doc.dpdk.org/guides/prog_guide/link_bonding_poll_mode_drv_lib.html
#[bond0]
#mode=4
#slave=0000:0a:00.0,slave=0000:0a:00.1
#primary=0000:0a:00.0
#mac=f0:98:38:xx:xx:xx
## opt argument
#socket_id=0
#xmit_policy=l23
#lsc_poll_period_ms=100
#up_delay=10
#down_delay=50

# Kni config: if enabled and method=reject,
# all packets that do not belong to the following tcp_port and udp_port
# will transmit to kernel; if method=accept, all packets that belong to
# the following tcp_port and udp_port will transmit to kernel.
#       type: exception path type, 0 means kni(must set meson -Ddisable_libs=flow_classif to re-enable kni in DPDK first), 1 means >
[kni]
type=1
enable=1
method=accept
# The format is same as port_list
tcp_port=80,443
#udp_port=53

# FreeBSD network performance tuning configurations.
# Most native FreeBSD configurations are supported.
[freebsd.boot]
# If use rack/bbr which depend HPTS, you should set a greater value of hz, such as 1000000 means a tick is 1us.
hz=100

# Block out a range of descriptors to avoid overlap
# with the kernel's descriptor space.
# You can increase this value according to your app.
fd_reserve=1024

kern.ipc.maxsockets=262144

net.inet.tcp.syncache.hashsize=4096
net.inet.tcp.syncache.bucketlimit=100

net.inet.tcp.tcbhashsize=65536
kern.ncallout=262144

kern.features.inet6=1

[freebsd.sysctl]
kern.ipc.somaxconn=32768
kern.ipc.maxsockbuf=16777216

net.link.ether.inet.maxhold=5

net.inet.tcp.fast_finwait2_recycle=1
net.inet.tcp.sendspace=16384
net.inet.tcp.recvspace=8192
#net.inet.tcp.nolocaltimewait=1
net.inet.tcp.cc.algorithm=cubic
net.inet.tcp.sendbuf_max=16777216
net.inet.tcp.recvbuf_max=16777216
net.inet.tcp.sendbuf_auto=1
net.inet.tcp.recvbuf_auto=1
net.inet.tcp.sendbuf_inc=16384
#net.inet.tcp.recvbuf_inc=524288
net.inet.tcp.sack.enable=1
net.inet.tcp.blackhole=1
net.inet.tcp.msl=2000
net.inet.tcp.delayed_ack=1
net.inet.tcp.rfc1323=1

net.inet.udp.blackhole=1
net.inet.ip.redirect=0
net.inet.ip.forwarding=0

net.inet6.ip6.auto_linklocal=1
net.inet6.ip6.accept_rtadv=2
net.inet6.icmp6.rediraccept=1
net.inet6.ip6.forwarding=0

# set default stacks:freebsd, rack or bbr, may be you need increase the value of parameter 'freebsd.boot.hz' while use rack or bbr.
net.inet.tcp.functions_default=freebsd
# need by bbr, should enable it.
net.inet.tcp.hpts.skip_swi=1
# Interval between calls to hpts_timeout_dir. default min 250us, max 256-512ms, default 512ms.
net.inet.tcp.hpts.minsleep=250
# [25600-51200]
net.inet.tcp.hpts.maxsleep=51200

ifconfig :

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet xxx.xxx.144.xx6  netmask 255.255.255.0  broadcast xxx.xxx.144.255
        inet6 fe80::83cc:xxxx:7871:xxxx  prefixlen 64  scopeid 0x20<link>
        ether ac:1f:6b:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 71017  bytes 13466904 (13.4 MB)
        RX errors 926  dropped 265  overruns 0  frame 926
        TX packets 1699  bytes 189808 (189.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xc7420000-c743ffff  

eno2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether ac:xx:6b:xx:9a:xx  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xc7400000-c741ffff  

ens1f0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 90:xx:ba:f0:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens1f1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 90:xx:ba:f0:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 342  bytes 29847 (29.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 342  bytes 29847 (29.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Then, I compiled the code and tried to run the hello world example using start.sh with a following output.

root@xxx-xxxx-xxx:/data/f-stack# ./start.sh 
./example/helloworld --conf config.ini --proc-type=primary --proc-id=0 
[dpdk]: lcore_mask=1
[dpdk]: channel=4
[dpdk]: promiscuous=1
[dpdk]: numa_on=1
[dpdk]: tx_csum_offoad_skip=0
[dpdk]: tso=0
[dpdk]: vlan_strip=1
[dpdk]: idle_sleep=0
[dpdk]: pkt_tx_delay=100
[dpdk]: symmetric_rss=0
[dpdk]: port_list=0
[dpdk]: nb_vdev=0
[dpdk]: nb_bond=0
[pcap]: enable=0
[pcap]: snaplen=96
[pcap]: savelen=16777216
[pcap]: savepath=.
[port0]: addr=xxx.xxx.144.xx6
[port0]: netmask=255.255.255.0
[port0]: broadcast=xxx.xxx.144.255
[port0]: gateway=xxx.xxx.144.1
[port0]: type=1
[port0]: enable=1
[port0]: method=reject
[port0]: tcp_port=80,443
[freebsd.boot]: hz=100
[freebsd.boot]: fd_reserve=1024
[freebsd.boot]: kern.ipc.maxsockets=262144
[freebsd.boot]: net.inet.tcp.syncache.hashsize=4096
[freebsd.boot]: net.inet.tcp.syncache.bucketlimit=100
[freebsd.boot]: net.inet.tcp.tcbhashsize=65536
[freebsd.boot]: kern.ncallout=262144
[freebsd.boot]: kern.features.inet6=1
[freebsd.sysctl]: kern.ipc.somaxconn=32768
[freebsd.sysctl]: kern.ipc.maxsockbuf=16777216
[freebsd.sysctl]: net.link.ether.inet.maxhold=5
[freebsd.sysctl]: net.inet.tcp.fast_finwait2_recycle=1
[freebsd.sysctl]: net.inet.tcp.sendspace=16384
[freebsd.sysctl]: net.inet.tcp.recvspace=8192
[freebsd.sysctl]: net.inet.tcp.cc.algorithm=cubic
[freebsd.sysctl]: net.inet.tcp.sendbuf_max=16777216
[freebsd.sysctl]: net.inet.tcp.recvbuf_max=16777216
[freebsd.sysctl]: net.inet.tcp.sendbuf_auto=1
[freebsd.sysctl]: net.inet.tcp.recvbuf_auto=1
[freebsd.sysctl]: net.inet.tcp.sendbuf_inc=16384
[freebsd.sysctl]: net.inet.tcp.sack.enable=1
[freebsd.sysctl]: net.inet.tcp.blackhole=1
[freebsd.sysctl]: net.inet.tcp.msl=2000
[freebsd.sysctl]: net.inet.tcp.delayed_ack=1
[freebsd.sysctl]: net.inet.tcp.rfc1323=1
[freebsd.sysctl]: net.inet.udp.blackhole=1
[freebsd.sysctl]: net.inet.ip.redirect=0
[freebsd.sysctl]: net.inet.ip.forwarding=0
[freebsd.sysctl]: net.inet6.ip6.auto_linklocal=1
[freebsd.sysctl]: net.inet6.ip6.accept_rtadv=2
[freebsd.sysctl]: net.inet6.icmp6.rediraccept=1
[freebsd.sysctl]: net.inet6.ip6.forwarding=0
[freebsd.sysctl]: net.inet.tcp.functions_default=freebsd
[freebsd.sysctl]: net.inet.tcp.hpts.skip_swi=1
[freebsd.sysctl]: net.inet.tcp.hpts.minsleep=250
[freebsd.sysctl]: net.inet.tcp.hpts.maxsleep=51200
f-stack -c1 -n4 --proc-type=primary 
EAL: Detected CPU lcores: 48
EAL: Detected NUMA nodes: 2
EAL: Detected static linkage of DPDK
EAL: Multi-process socket /var/run/dpdk/rte/mp_socket
EAL: Selected IOVA mode 'PA'
EAL: Probe PCI driver: net_e1000_igb (8086:1521) device: 0000:01:00.0 (socket 0)
TELEMETRY: No legacy callbacks, legacy socket not created
lcore: 0, port: 0, queue: 0
create mbuf pool on socket 0
create ring:dispatch_ring_p0_q0 success, 2047 ring entries are now free!
Port 0 MAC:AC:1F:6B:XX:XX:XX
Port 0 modified RSS hash function based on hardware support,requested:0x2003ffffc configured:0x38d34
RX checksum offload supported
TX ip checksum offload supported
TX TCP&UDP checksum offload supported
TSO is disabled
port[0]: rss table size: 128
set port 0 to promiscuous mode ok

Checking link status.................................done
Port 0 Link Up - speed 1000 Mbps - full-duplex
link_elf_lookup_symbol: missing symbol hash table
link_elf_lookup_symbol: missing symbol hash table
Timecounters tick every 10.000 msec
WARNING: Adding ifaddrs to all fibs has been turned off by default. Consider tuning net.add_addr_allfibs if needed
Attempting to load tcp_bbr
tcp_bbr is now available
TCP Hpts created 1 swi interrupt threads and bound 0 to cpus
Timecounter "ff_clock" frequency 100 Hz quality 1
TCP_ratelimit: Is now initialized
f-stack-0: No addr6 config found.
f-stack-0: Ethernet address: ac:1f:6b:xx:xx:xx

ff_ifconfig :

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet 127.0.0.1 netmask 0xff000000
    inet6 ::1 prefixlen 128
    inet6 fe80::1 prefixlen 64 scopeid 0x1
    groups: lo
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
f-stack-0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=3<RXCSUM,TXCSUM>
    ether ac:1f:6b:xx:xx:xx
    inet6 fe80::xxxx:6bff:xxxx:9aea prefixlen 64 scopeid 0x2
    inet xxx.xxx.144.xx6 netmask 0xffffff00 broadcast xxx.xxx.144.255
    nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>

ff_netstat -anr :

Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            xxx.xxx.144.1      UGS    f-stack-
127.0.0.1          127.0.0.1          UH          lo0
xxx.xxx.144.0/24   127.0.0.1          U      f-stack-
xxx.xxx.144.xx6    xxx.xxx.144.xx6    UHS         lo0

Internet6:
Destination                       Gateway                       Flags     Netif Expire
::1                               ::1                           UHS         lo0
/64                               ::1                           U           lo0
fe80::1                           fe80::1                       UHS         lo0
/64              ``                 fe80::1                       U      f-stack-
fe80::xxxx:6bff:xxxx:9aea         fe80::xxxx:6bff:xxxx:9aea     UHS         lo0

ff_arp -a :

? (xxx.xxx.144.xx6) at ac:1f:6b:xx:xx:xx on f-stack-0 permanent [ethernet]

It's usually a configuration issue, you can show your config.inif and ff_ifconfig/ff_netstat -anr/ff_arp -a info, and pcap, etc.

jfb8856606 commented 11 months ago

May be you need config veth0 in kernel like this in README to enable kni.