NetSys / bess

BESS: Berkeley Extensible Software Switch
Other
313 stars 156 forks source link

Encap adds fields twice #993

Open yiannisy opened 4 years ago

yiannisy commented 4 years ago

Hi,

I want to add an Ethernet header to L3 packets, and observe weird behavior from Encap modules (both GenericEncap and EtherEncap). It will occasionally add the Ethernet header twice. This doesn't seem to be triggered by the packet contents, it's random and happens at 10-20% of packets.

The code below will recreate the results. I also attach the L3 and L2 packet captures. I've tried with different input sources, like Source/Rewrite, as well as playing packets out from a L3 pcap file, and the same issue comes up again.

Is this a known issue?

import scapy.all as scapy
import os

pkt_size = int($BESS_PKT_SIZE!'60')
assert(60 <= pkt_size <= 1522)

ip = scapy.IP(src='10.0.0.1', dst='10.0.0.2', tos=1)   # dst IP is overwritten
tcp = scapy.TCP(sport=10001, dport=10002)
payload = ('hello' + '0123456789' * 200)[:pkt_size-len(ip/tcp)]
pkt = ip/tcp/payload
pkt_data = bytes(pkt)

ether_encap_up::EtherEncap()
s_up::Sink()
rewrite::Rewrite(templates=[pkt_data])

Source()->rewrite->SetMetadata(attrs=[{'name': 'ether_src', 'size': 6, 'value_bin': '\x02\x01\x02\x03\x04\x05'},{'name': 'ether_dst', 'size': 6, 'value_bin': '\x02\x0a\x0b\x0c\x0d\x0e'}, {'name': 'ether_\
type', 'size':2, 'value_bin':'\x08\x00'}]) -> ether_encap_up -> s_up

open('/tmp/l2.pcap','w').close()
open('/tmp/l3.pcap','w').close()
bess.tcpdump_gate(True, 'test', "ether_encap_up", gate=0, direction="out", fifo="/tmp/l2.pcap")
bess.tcpdump_gate(True, 'test', "rewrite", gate=0, direction="out", fifo="/tmp/l3.pcap")
yiannisy commented 4 years ago

Links to L2/L3 packet captures. First 30+ packets on L2.pcap have double ethernet headers.

L2 PCAP L3 PCAP