switchd segfaults

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

switchd segfaults

Leon Lagodny
>Synopsis:     switchd segfaults at random intervals
>Category:    system
>Environment:
    System      : OpenBSD 6.4
    Details     : OpenBSD 6.4-stable (CUSTOM) #1: Sun Mar  3 07:52:19 CET 2019
             [hidden email]:/usr/src/sys/arch/amd64/compile/CUSTOM

    Architecture: OpenBSD.amd64
    Machine     : amd64
>Description:
    I've been running an APU2 as my home router.
    Unfortunately switchd crashes at seemingly random intervals causing the interface to stop forwarding packets.
    Switchd does not log anything related to the crash to /var/log/daemon so I recorded a coredump according to
    the bgp example in sysctl(8).
    The only thing custom about the kernel I'm running is 'option PPPOE_TERM_UNKNOWN_SESSIONS' and I can
    confirm that this also happens with the default kernel.

gdb:
(gdb) bt full
#0  0x000000334fc35af0 in _libc_SHA1Pad (context=0x34336bb5e8) at /usr/src/lib/libc/hash/sha1.c:132
        finalcount = 0x7f7ffffc78b8 "\222?8s7\031P\0257\r"
        i = Cannot access memory at address 0x7
(gdb) where
#0  0x000000334fc35af0 in _libc_SHA1Pad (context=0x34336bb5e8) at /usr/src/lib/libc/hash/sha1.c:132
#1  0x0000003422e1c350 in ibuf_add (buf=0x338ead7680, data=0x0, len=1494) at /usr/src/lib/libutil/imsg-buffer.c:97
#2  0x0000003422e1aa2e in imsg_add (msg=0x338ead7680, data=Variable "data" is not available.
) at /usr/src/lib/libutil/imsg.c:240
#3  0x000000313390ab56 in ?? () from /usr/sbin/switchd
#4  0x000000313390cb32 in ?? () from /usr/sbin/switchd
#5  0x0000003133909672 in ?? () from /usr/sbin/switchd
#6  0x0000003133911625 in ?? () from /usr/sbin/switchd
#7  0x0000003133911157 in ?? () from /usr/sbin/switchd
#8  0x00000034308dbbbd in event_base_loop (base=0x33c2016000, flags=0) at /usr/src/lib/libevent/event.c:350
#9  0x0000003133903a98 in ?? () from /usr/sbin/switchd
#10 0x0000003133902a8b in ?? () from /usr/sbin/switchd
#11 0x0000003133907660 in ?? () from /usr/sbin/switchd
#12 0x0000003133900b46 in ?? () from /usr/sbin/switchd
#13 0x0000000000000000 in ?? ()

/etc/switchd.conf:
listen on 127.0.0.1 tls port 6633
device "/dev/switch0"

/etc/hostname.switch0:
addlocal vether0
add em0
add em1
up

/etc/hostname.vether0:
inet 10.0.1.1 255.255.240.0
inet alias 10.0.1.2 255.255.240.0
up

dmesg:
OpenBSD 6.4-stable (CUSTOM) #1: Sun Mar  3 07:52:19 CET 2019
    [hidden email]:/usr/src/sys/arch/amd64/compile/CUSTOM
real mem = 4261076992 (4063MB)
avail mem = 4122771456 (3931MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xdffb7020 (7 entries)
bios0: vendor coreboot version "88a4f96" date 03/11/2016
bios0: PC Engines apu2
acpi0 at bios0: rev 2
acpi0: sleep states S0 S1 S2 S3 S4 S5
acpi0: tables DSDT FACP SSDT APIC HEST SSDT SSDT HPET
acpi0: wakeup devices PWRB(S4) PBR4(S4) PBR5(S4) PBR6(S4) PBR7(S4) PBR8(S4) UOH1(S3) UOH3(S3) UOH5(S3) XHC0(S4)
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD GX-412TC SOC, 998.26 MHz, 16-30-01
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,DBKP,PERFTSC,PCTRL3,ITSC,BMI1,XSAVEOPT
cpu0: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB 64b/line 16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 99MHz
cpu0: mwait min=64, max=64, IBE
cpu at mainbus0: not configured
cpu at mainbus0: not configured
cpu at mainbus0: not configured
ioapic0 at mainbus0: apid 4 pa 0xfec00000, version 21, 24 pins
ioapic1 at mainbus0: apid 5 pa 0xfec20000, version 21, 32 pins, remapped
acpihpet0 at acpi0: 14318180 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus -1 (PBR4)
acpiprt2 at acpi0: bus 1 (PBR5)
acpiprt3 at acpi0: bus 2 (PBR6)
acpiprt4 at acpi0: bus 3 (PBR7)
acpiprt5 at acpi0: bus -1 (PBR8)
acpicpu0 at acpi0: C2(0@400 io@0x1771), C1(@1 halt!), PSS
acpibtn0 at acpi0: PWRB
acpicmos0 at acpi0
cpu0: 998 MHz: speeds: 1000 800 600 MHz
pci0 at mainbus0 bus 0
pchb0 at pci0 dev 0 function 0 "AMD AMD64 16h Root Complex" rev 0x00
pchb1 at pci0 dev 2 function 0 "AMD AMD64 16h Host" rev 0x00
ppb0 at pci0 dev 2 function 2 "AMD AMD64 16h PCIE" rev 0x00: msi
pci1 at ppb0 bus 1
em0 at pci1 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:38
ppb1 at pci0 dev 2 function 3 "AMD AMD64 16h PCIE" rev 0x00: msi
pci2 at ppb1 bus 2
em1 at pci2 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:39
ppb2 at pci0 dev 2 function 4 "AMD AMD64 16h PCIE" rev 0x00: msi
pci3 at ppb2 bus 3
em2 at pci3 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:3a
ccp0 at pci0 dev 8 function 0 "AMD Cryptographic Co-processor v3" rev 0x00
xhci0 at pci0 dev 16 function 0 "AMD Bolton xHCI" rev 0x11: msi, xHCI 1.0
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "AMD xHCI root hub" rev 3.00/1.00 addr 1
ahci0 at pci0 dev 17 function 0 "AMD Hudson-2 SATA" rev 0x40: apic 4 int 19, AHCI 1.3
ahci0: port 0: 6.0Gb/s
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 0 lun 0: <ATA, SATA SSD, SBFM> SCSI3 0/direct fixed naa.5000000000000000
sd0: 15272MB, 512 bytes/sector, 31277232 sectors, thin
ehci0 at pci0 dev 19 function 0 "AMD Hudson-2 USB2" rev 0x39: apic 4 int 18
usb1 at ehci0: USB revision 2.0
uhub1 at usb1 configuration 1 interface 0 "AMD EHCI root hub" rev 2.00/1.00 addr 1
piixpm0 at pci0 dev 20 function 0 "AMD Hudson-2 SMBus" rev 0x42: SMBus disabled
pcib0 at pci0 dev 20 function 3 "AMD Hudson-2 LPC" rev 0x11
sdhc0 at pci0 dev 20 function 7 "AMD Bolton SD/MMC" rev 0x01: apic 4 int 16
sdhc0: SDHC 2.0, 63 MHz base clock
sdmmc0 at sdhc0: 4-bit, sd high-speed, mmc high-speed, dma
pchb2 at pci0 dev 24 function 0 "AMD AMD64 16h Link Cfg" rev 0x00
pchb3 at pci0 dev 24 function 1 "AMD AMD64 16h Address Map" rev 0x00
pchb4 at pci0 dev 24 function 2 "AMD AMD64 16h DRAM Cfg" rev 0x00
km0 at pci0 dev 24 function 3 "AMD AMD64 16h Misc Cfg" rev 0x00
pchb5 at pci0 dev 24 function 4 "AMD AMD64 16h CPU Power" rev 0x00
pchb6 at pci0 dev 24 function 5 "AMD AMD64 16h Misc Cfg" rev 0x00
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com0: console
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
wbsio0 at isa0 port 0x2e/2: NCT5104D rev 0x52
vmm0 at mainbus0: SVM/RVI
uhub2 at uhub1 port 1 configuration 1 interface 0 "Advanced Micro Devices product 0x7900" rev 2.00/0.18 addr 2
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (c13267e44c837452.a) swap on sd0b dump on sd0b
WARNING: / was not properly unmounted
Process (pid 1) got signal 31

usbdevs:
Controller /dev/usb0:
addr 01: 1022:0000 AMD, xHCI root hub
     super speed, self powered, config 1, rev 1.00
     driver: uhub0
Controller /dev/usb1:
addr 01: 1022:0000 AMD, EHCI root hub
     high speed, self powered, config 1, rev 1.00
     driver: uhub1
addr 02: 0438:7900 Advanced Micro Devices, product 0x7900
     high speed, self powered, config 1, rev 0.18
     driver: uhub2
Reply | Threaded
Open this post in threaded view
|

Re: switchd segfaults

Long Wu Yuan



Thanks,
; Long

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, March 8, 2019 8:23 AM, Leon Lagodny <[hidden email]> wrote:

> >Synopsis: switchd segfaults at random intervals
>
> > Category: system
> > Environment:
>
>     System      : OpenBSD 6.4
>     Details     : OpenBSD 6.4-stable (CUSTOM) #1: Sun Mar  3 07:52:19 CET 2019
>              [hidden email]:/usr/src/sys/arch/amd64/compile/CUSTOM
>
>
> Architecture: OpenBSD.amd64
> Machine : amd64
>
> > Description:
>
>     I've been running an APU2 as my home router.
>     Unfortunately switchd crashes at seemingly random intervals causing the interface to stop forwarding packets.
>     Switchd does not log anything related to the crash to /var/log/daemon so I recorded a coredump according to
>     the bgp example in sysctl(8).
>     The only thing custom about the kernel I'm running is 'option PPPOE_TERM_UNKNOWN_SESSIONS' and I can
>     confirm that this also happens with the default kernel.
>
>
> gdb:
> (gdb) bt full
> #0 0x000000334fc35af0 in _libc_SHA1Pad (context=0x34336bb5e8) at /usr/src/lib/libc/hash/sha1.c:132
> finalcount = 0x7f7ffffc78b8 "\222?8s7\031P\0257\r"
> i = Cannot access memory at address 0x7
> (gdb) where
> #0 0x000000334fc35af0 in _libc_SHA1Pad (context=0x34336bb5e8) at /usr/src/lib/libc/hash/sha1.c:132
> #1 0x0000003422e1c350 in ibuf_add (buf=0x338ead7680, data=0x0, len=1494) at /usr/src/lib/libutil/imsg-buffer.c:97
> #2 0x0000003422e1aa2e in imsg_add (msg=0x338ead7680, data=Variable "data" is not available.
> ) at /usr/src/lib/libutil/imsg.c:240
> #3 0x000000313390ab56 in ?? () from /usr/sbin/switchd
> #4 0x000000313390cb32 in ?? () from /usr/sbin/switchd
> #5 0x0000003133909672 in ?? () from /usr/sbin/switchd
> #6 0x0000003133911625 in ?? () from /usr/sbin/switchd
> #7 0x0000003133911157 in ?? () from /usr/sbin/switchd
> #8 0x00000034308dbbbd in event_base_loop (base=0x33c2016000, flags=0) at /usr/src/lib/libevent/event.c:350
> #9 0x0000003133903a98 in ?? () from /usr/sbin/switchd
> #10 0x0000003133902a8b in ?? () from /usr/sbin/switchd
> #11 0x0000003133907660 in ?? () from /usr/sbin/switchd
> #12 0x0000003133900b46 in ?? () from /usr/sbin/switchd
> #13 0x0000000000000000 in ?? ()
>
> /etc/switchd.conf:
> listen on 127.0.0.1 tls port 6633
> device "/dev/switch0"
>
> /etc/hostname.switch0:
> addlocal vether0
> add em0
> add em1
> up
>
> /etc/hostname.vether0:
> inet 10.0.1.1 255.255.240.0
> inet alias 10.0.1.2 255.255.240.0
> up
>
> dmesg:
> OpenBSD 6.4-stable (CUSTOM) #1: Sun Mar 3 07:52:19 CET 2019
> [hidden email]:/usr/src/sys/arch/amd64/compile/CUSTOM
> real mem = 4261076992 (4063MB)
> avail mem = 4122771456 (3931MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xdffb7020 (7 entries)
> bios0: vendor coreboot version "88a4f96" date 03/11/2016
> bios0: PC Engines apu2
> acpi0 at bios0: rev 2
> acpi0: sleep states S0 S1 S2 S3 S4 S5
> acpi0: tables DSDT FACP SSDT APIC HEST SSDT SSDT HPET
> acpi0: wakeup devices PWRB(S4) PBR4(S4) PBR5(S4) PBR6(S4) PBR7(S4) PBR8(S4) UOH1(S3) UOH3(S3) UOH5(S3) XHC0(S4)
> acpitimer0 at acpi0: 3579545 Hz, 32 bits
> acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: AMD GX-412TC SOC, 998.26 MHz, 16-30-01
> cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,DBKP,PERFTSC,PCTRL3,ITSC,BMI1,XSAVEOPT
> cpu0: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB 64b/line 16-way L2 cache
> cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
> cpu0: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
> cpu0: smt 0, core 0, package 0
> mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
> cpu0: apic clock running at 99MHz
> cpu0: mwait min=64, max=64, IBE
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> ioapic0 at mainbus0: apid 4 pa 0xfec00000, version 21, 24 pins
> ioapic1 at mainbus0: apid 5 pa 0xfec20000, version 21, 32 pins, remapped
> acpihpet0 at acpi0: 14318180 Hz
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpiprt1 at acpi0: bus -1 (PBR4)
> acpiprt2 at acpi0: bus 1 (PBR5)
> acpiprt3 at acpi0: bus 2 (PBR6)
> acpiprt4 at acpi0: bus 3 (PBR7)
> acpiprt5 at acpi0: bus -1 (PBR8)
> acpicpu0 at acpi0: C2(0@400 io@0x1771), C1(@1 halt!), PSS
> acpibtn0 at acpi0: PWRB
> acpicmos0 at acpi0
> cpu0: 998 MHz: speeds: 1000 800 600 MHz
> pci0 at mainbus0 bus 0
> pchb0 at pci0 dev 0 function 0 "AMD AMD64 16h Root Complex" rev 0x00
> pchb1 at pci0 dev 2 function 0 "AMD AMD64 16h Host" rev 0x00
> ppb0 at pci0 dev 2 function 2 "AMD AMD64 16h PCIE" rev 0x00: msi
> pci1 at ppb0 bus 1
> em0 at pci1 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:38
> ppb1 at pci0 dev 2 function 3 "AMD AMD64 16h PCIE" rev 0x00: msi
> pci2 at ppb1 bus 2
> em1 at pci2 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:39
> ppb2 at pci0 dev 2 function 4 "AMD AMD64 16h PCIE" rev 0x00: msi
> pci3 at ppb2 bus 3
> em2 at pci3 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:3a
> ccp0 at pci0 dev 8 function 0 "AMD Cryptographic Co-processor v3" rev 0x00
> xhci0 at pci0 dev 16 function 0 "AMD Bolton xHCI" rev 0x11: msi, xHCI 1.0
> usb0 at xhci0: USB revision 3.0
> uhub0 at usb0 configuration 1 interface 0 "AMD xHCI root hub" rev 3.00/1.00 addr 1
> ahci0 at pci0 dev 17 function 0 "AMD Hudson-2 SATA" rev 0x40: apic 4 int 19, AHCI 1.3
> ahci0: port 0: 6.0Gb/s
> scsibus1 at ahci0: 32 targets
> sd0 at scsibus1 targ 0 lun 0: <ATA, SATA SSD, SBFM> SCSI3 0/direct fixed naa.5000000000000000
> sd0: 15272MB, 512 bytes/sector, 31277232 sectors, thin
> ehci0 at pci0 dev 19 function 0 "AMD Hudson-2 USB2" rev 0x39: apic 4 int 18
> usb1 at ehci0: USB revision 2.0
> uhub1 at usb1 configuration 1 interface 0 "AMD EHCI root hub" rev 2.00/1.00 addr 1
> piixpm0 at pci0 dev 20 function 0 "AMD Hudson-2 SMBus" rev 0x42: SMBus disabled
> pcib0 at pci0 dev 20 function 3 "AMD Hudson-2 LPC" rev 0x11
> sdhc0 at pci0 dev 20 function 7 "AMD Bolton SD/MMC" rev 0x01: apic 4 int 16
> sdhc0: SDHC 2.0, 63 MHz base clock
> sdmmc0 at sdhc0: 4-bit, sd high-speed, mmc high-speed, dma
> pchb2 at pci0 dev 24 function 0 "AMD AMD64 16h Link Cfg" rev 0x00
> pchb3 at pci0 dev 24 function 1 "AMD AMD64 16h Address Map" rev 0x00
> pchb4 at pci0 dev 24 function 2 "AMD AMD64 16h DRAM Cfg" rev 0x00
> km0 at pci0 dev 24 function 3 "AMD AMD64 16h Misc Cfg" rev 0x00
> pchb5 at pci0 dev 24 function 4 "AMD AMD64 16h CPU Power" rev 0x00
> pchb6 at pci0 dev 24 function 5 "AMD AMD64 16h Misc Cfg" rev 0x00
> isa0 at pcib0
> isadma0 at isa0
> com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
> com0: console
> com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
> pcppi0 at isa0 port 0x61
> spkr0 at pcppi0
> lpt0 at isa0 port 0x378/4 irq 7
> wbsio0 at isa0 port 0x2e/2: NCT5104D rev 0x52
> vmm0 at mainbus0: SVM/RVI
> uhub2 at uhub1 port 1 configuration 1 interface 0 "Advanced Micro Devices product 0x7900" rev 2.00/0.18 addr 2
> vscsi0 at root
> scsibus2 at vscsi0: 256 targets
> softraid0 at root
> scsibus3 at softraid0: 256 targets
> root on sd0a (c13267e44c837452.a) swap on sd0b dump on sd0b
> WARNING: / was not properly unmounted
> Process (pid 1) got signal 31
>
> usbdevs:
> Controller /dev/usb0:
> addr 01: 1022:0000 AMD, xHCI root hub
> super speed, self powered, config 1, rev 1.00
> driver: uhub0
> Controller /dev/usb1:
> addr 01: 1022:0000 AMD, EHCI root hub
> high speed, self powered, config 1, rev 1.00
> driver: uhub1
> addr 02: 0438:7900 Advanced Micro Devices, product 0x7900
> high speed, self powered, config 1, rev 0.18
> driver: uhub2

I have not experienced on current.
Thanks,
; Long

Reply | Threaded
Open this post in threaded view
|

Re: switchd segfaults

Anthony J. Bentley-4
In reply to this post by Leon Lagodny
Hi,

Leon Lagodny writes:

> #3  0x000000313390ab56 in ?? () from /usr/sbin/switchd
> #4  0x000000313390cb32 in ?? () from /usr/sbin/switchd
> #5  0x0000003133909672 in ?? () from /usr/sbin/switchd
> #6  0x0000003133911625 in ?? () from /usr/sbin/switchd
> #7  0x0000003133911157 in ?? () from /usr/sbin/switchd
> #8  0x00000034308dbbbd in event_base_loop (base=0x33c2016000, flags=0) at /us
> r/src/lib/libevent/event.c:350
> #9  0x0000003133903a98 in ?? () from /usr/sbin/switchd
> #10 0x0000003133902a8b in ?? () from /usr/sbin/switchd
> #11 0x0000003133907660 in ?? () from /usr/sbin/switchd
> #12 0x0000003133900b46 in ?? () from /usr/sbin/switchd
> #13 0x0000000000000000 in ?? ()

Please rebuild switchd with DEBUG=-g in /etc/mk.conf, so that your
backtrace will contain debug symbols.

I've been seeing switchd die regularly under load on my router, but
my backtrace looks a little different:


Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000f66a36d82d0 in memcpy (dst0=0xf6716959028, src0=<optimized out>,
    length=60) at /usr/src/lib/libc/string/memcpy.c:103
103     /usr/src/lib/libc/string/memcpy.c: No such file or directory.
(gdb) bt
#0  0x00000f66a36d82d0 in memcpy (dst0=0xf6716959028, src0=<optimized out>,
    length=60) at /usr/src/lib/libc/string/memcpy.c:103
#1  0x00000f66f3b3ba50 in ibuf_add (buf=0xf66bbd7e900, data=0x0, len=60)
    at /usr/src/lib/libutil/imsg-buffer.c:97
#2  0x00000f66f3b3fc2b in imsg_add (msg=0xf66bbd7e900, data=0x0, datalen=60)
    at /usr/src/lib/libutil/imsg.c:240
#3  0x00000f64239db49d in ofp13_packet_in (sc=0xf66d4cc24d0,
    con=0xf66d4cca400, ih=<optimized out>, ibuf=<optimized out>)
    at ofp13.c:1150
#4  0x00000f64239dd52c in ofp13_input (sc=0xf66d4cc24d0, con=0xf66d4cca400,
    oh=0xf666d4f2000, ibuf=0xf66bbd7a800) at ofp13.c:621
#5  0x00000f64239d9d18 in ofp_input (con=0xf66d4cca400, ibuf=0xf66bbd7a800)
    at ofp.c:159
#6  0x00000f64239e20d0 in ofrelay_input_done (con=0xf66d4cca400,
    buf=0xf66bbd7a800) at ofrelay.c:282
#7  0x00000f64239e1c07 in ofrelay_event (fd=8, event=2, arg=0xf66d4cca400)
    at ofrelay.c:138
#8  0x00000f665ca13f92 in event_process_active (base=<optimized out>)
    at /usr/src/lib/libevent/event.c:350
#9  event_base_loop (base=0xf66bbd7c800, flags=0)
    at /usr/src/lib/libevent/event.c:502
#10 0x00000f64239d410b in proc_run (ps=0xf66d4cc24d0, p=0xf64239e7000 <procs>,
    procs=0xf64239e7180 <procs>, nproc=2, run=0xf64239d9a00 <ofp_run>, arg=0x0)
    at proc.c:602
#11 0x00000f64239d30a4 in proc_init (ps=0xf6716959028, procs=<optimized out>,
    nproc=<optimized out>, debug=0, argc=56, argv=0xf6716959028,
    proc_id=PROC_OFP) at proc.c:260
#12 0x00000f64239d7d27 in main (argc=5, argv=0x7f7ffffd3a58) at switchd.c:187
(gdb)

Reply | Threaded
Open this post in threaded view
|

Re: switchd segfaults

Leon Lagodny
In reply to this post by Leon Lagodny
Ok, it took a while for switchd to crash again. Here the output of gdb with debugging  symbols enabled.

(gdb) bt full
#0  0x00000b62ca3e7a50 in _libc_yp_first (indomain=0xb62cf99f440 "", inmap=0xb62eaf445e8 '' <repeats 200 times>..., outkey=0xb62ca3796ff, outkeylen=0x0, outval=0xd, outvallen=0x5c0) from /usr/lib/libc.so.92.5
        ysd = (struct dom_binding *) 0xb5f00000001
        r = Variable "r" is not available.
(gdb) where
#0  0x00000b62ca3e7a50 in _libc_yp_first (indomain=0xb62cf99f440 "", inmap=0xb62eaf445e8 '' <repeats 200 times>..., outkey=0xb62ca3796ff, outkeylen=0x0, outval=0xd, outvallen=0x5c0) from /usr/lib/libc.so.92.5
#1  0x00000b62d5e28350 in ibuf_add (buf=0xb62cf99f440, data=0x0, len=1494) at /usr/src/lib/libutil/imsg-buffer.c:97
#2  0x00000b62d5e26a2e in imsg_add (msg=0xb62cf99f440, data=Variable "data" is not available.
) at /usr/src/lib/libutil/imsg.c:240
#3  0x00000b5ffe80ab56 in ofp13_packet_in (sc=0xb62cf99a4d0, con=0xb6263883c00, ih=Variable "ih" is not available.
) at /usr/src/usr.sbin/switchd/ofp13.c:1150
#4  0x00000b5ffe80cb32 in ofp13_input (sc=0xb62cf99a4d0, con=0xb6263883c00, oh=0xb624549e000, ibuf=0xb626387da80) at /usr/src/usr.sbin/switchd/ofp13.c:621
#5  0x00000b5ffe809672 in ofp_input (con=0xb6263883c00, ibuf=0xb626387da80) at /usr/src/usr.sbin/switchd/ofp.c:159
#6  0x00000b5ffe811625 in ofrelay_input_done (con=0xb6263883c00, buf=0xb626387da80) at /usr/src/usr.sbin/switchd/ofrelay.c:282
#7  0x00000b5ffe811157 in ofrelay_event (fd=8, event=2, arg=0xb6263883c00) at /usr/src/usr.sbin/switchd/ofrelay.c:138
#8  0x00000b62394a7bbd in event_base_loop (base=0xb6263883400, flags=0) at /usr/src/lib/libevent/event.c:350
#9  0x00000b5ffe803a98 in proc_run (ps=0xb62cf99a4d0, p=0xb5ffea22000, procs=0xb5ffea22180, nproc=2, run=0xb5ffe809360 <ofp_run>, arg=0x0) at /usr/src/usr.sbin/switchd/proc.c:602
#10 0x00000b5ffe802a8b in proc_init (ps=Variable "ps" is not available.
) at /usr/src/usr.sbin/switchd/proc.c:260
#11 0x00000b5ffe807660 in main (argc=5, argv=0x7f7ffffdd658) at /usr/src/usr.sbin/switchd/switchd.c:187

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, March 8, 2019 2:53 AM, Leon Lagodny <[hidden email]> wrote:

>>Synopsis:     switchd segfaults at random intervals
>>Category:    system
>>Environment:
>     System      : OpenBSD 6.4
>     Details     : OpenBSD 6.4-stable (CUSTOM) #1: Sun Mar  3 07:52:19 CET 2019
>              [hidden email]:/usr/src/sys/arch/amd64/compile/CUSTOM
>
>     Architecture: OpenBSD.amd64
>     Machine     : amd64
>>Description:
>     I've been running an APU2 as my home router.
>     Unfortunately switchd crashes at seemingly random intervals causing the interface to stop forwarding packets.
>     Switchd does not log anything related to the crash to /var/log/daemon so I recorded a coredump according to
>     the bgp example in sysctl(8).
>     The only thing custom about the kernel I'm running is 'option PPPOE_TERM_UNKNOWN_SESSIONS' and I can
>     confirm that this also happens with the default kernel.
>
> gdb:
> (gdb) bt full
> #0  0x000000334fc35af0 in _libc_SHA1Pad (context=0x34336bb5e8) at /usr/src/lib/libc/hash/sha1.c:132
>         finalcount = 0x7f7ffffc78b8 "\222?8s7\031P\0257\r"
>         i = Cannot access memory at address 0x7
> (gdb) where
> #0  0x000000334fc35af0 in _libc_SHA1Pad (context=0x34336bb5e8) at /usr/src/lib/libc/hash/sha1.c:132
> #1  0x0000003422e1c350 in ibuf_add (buf=0x338ead7680, data=0x0, len=1494) at /usr/src/lib/libutil/imsg-buffer.c:97
> #2  0x0000003422e1aa2e in imsg_add (msg=0x338ead7680, data=Variable "data" is not available.
> ) at /usr/src/lib/libutil/imsg.c:240
> #3  0x000000313390ab56 in ?? () from /usr/sbin/switchd
> #4  0x000000313390cb32 in ?? () from /usr/sbin/switchd
> #5  0x0000003133909672 in ?? () from /usr/sbin/switchd
> #6  0x0000003133911625 in ?? () from /usr/sbin/switchd
> #7  0x0000003133911157 in ?? () from /usr/sbin/switchd
> #8  0x00000034308dbbbd in event_base_loop (base=0x33c2016000, flags=0) at /usr/src/lib/libevent/event.c:350
> #9  0x0000003133903a98 in ?? () from /usr/sbin/switchd
> #10 0x0000003133902a8b in ?? () from /usr/sbin/switchd
> #11 0x0000003133907660 in ?? () from /usr/sbin/switchd
> #12 0x0000003133900b46 in ?? () from /usr/sbin/switchd
> #13 0x0000000000000000 in ?? ()
>
> /etc/switchd.conf:
> listen on 127.0.0.1 tls port 6633
> device "/dev/switch0"
>
> /etc/hostname.switch0:
> addlocal vether0
> add em0
> add em1
> up
>
> /etc/hostname.vether0:
> inet 10.0.1.1 255.255.240.0
> inet alias 10.0.1.2 255.255.240.0
> up
>
> dmesg:
> OpenBSD 6.4-stable (CUSTOM) #1: Sun Mar  3 07:52:19 CET 2019
>     [hidden email]:/usr/src/sys/arch/amd64/compile/CUSTOM
> real mem = 4261076992 (4063MB)
> avail mem = 4122771456 (3931MB)
> mpath0 at root
> scsibus0 at mpath0: 256 targets
> mainbus0 at root
> bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xdffb7020 (7 entries)
> bios0: vendor coreboot version "88a4f96" date 03/11/2016
> bios0: PC Engines apu2
> acpi0 at bios0: rev 2
> acpi0: sleep states S0 S1 S2 S3 S4 S5
> acpi0: tables DSDT FACP SSDT APIC HEST SSDT SSDT HPET
> acpi0: wakeup devices PWRB(S4) PBR4(S4) PBR5(S4) PBR6(S4) PBR7(S4) PBR8(S4) UOH1(S3) UOH3(S3) UOH5(S3) XHC0(S4)
> acpitimer0 at acpi0: 3579545 Hz, 32 bits
> acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
> cpu0 at mainbus0: apid 0 (boot processor)
> cpu0: AMD GX-412TC SOC, 998.26 MHz, 16-30-01
> cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,DBKP,PERFTSC,PCTRL3,ITSC,BMI1,XSAVEOPT
> cpu0: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB 64b/line 16-way L2 cache
> cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
> cpu0: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
> cpu0: smt 0, core 0, package 0
> mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
> cpu0: apic clock running at 99MHz
> cpu0: mwait min=64, max=64, IBE
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> cpu at mainbus0: not configured
> ioapic0 at mainbus0: apid 4 pa 0xfec00000, version 21, 24 pins
> ioapic1 at mainbus0: apid 5 pa 0xfec20000, version 21, 32 pins, remapped
> acpihpet0 at acpi0: 14318180 Hz
> acpiprt0 at acpi0: bus 0 (PCI0)
> acpiprt1 at acpi0: bus -1 (PBR4)
> acpiprt2 at acpi0: bus 1 (PBR5)
> acpiprt3 at acpi0: bus 2 (PBR6)
> acpiprt4 at acpi0: bus 3 (PBR7)
> acpiprt5 at acpi0: bus -1 (PBR8)
> acpicpu0 at acpi0: C2(0@400 io@0x1771), C1(@1 halt!), PSS
> acpibtn0 at acpi0: PWRB
> acpicmos0 at acpi0
> cpu0: 998 MHz: speeds: 1000 800 600 MHz
> pci0 at mainbus0 bus 0
> pchb0 at pci0 dev 0 function 0 "AMD AMD64 16h Root Complex" rev 0x00
> pchb1 at pci0 dev 2 function 0 "AMD AMD64 16h Host" rev 0x00
> ppb0 at pci0 dev 2 function 2 "AMD AMD64 16h PCIE" rev 0x00: msi
> pci1 at ppb0 bus 1
> em0 at pci1 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:38
> ppb1 at pci0 dev 2 function 3 "AMD AMD64 16h PCIE" rev 0x00: msi
> pci2 at ppb1 bus 2
> em1 at pci2 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:39
> ppb2 at pci0 dev 2 function 4 "AMD AMD64 16h PCIE" rev 0x00: msi
> pci3 at ppb2 bus 3
> em2 at pci3 dev 0 function 0 "Intel I210" rev 0x03: msi, address 00:0d:b9:46:2b:3a
> ccp0 at pci0 dev 8 function 0 "AMD Cryptographic Co-processor v3" rev 0x00
> xhci0 at pci0 dev 16 function 0 "AMD Bolton xHCI" rev 0x11: msi, xHCI 1.0
> usb0 at xhci0: USB revision 3.0
> uhub0 at usb0 configuration 1 interface 0 "AMD xHCI root hub" rev 3.00/1.00 addr 1
> ahci0 at pci0 dev 17 function 0 "AMD Hudson-2 SATA" rev 0x40: apic 4 int 19, AHCI 1.3
> ahci0: port 0: 6.0Gb/s
> scsibus1 at ahci0: 32 targets
> sd0 at scsibus1 targ 0 lun 0: <ATA, SATA SSD, SBFM> SCSI3 0/direct fixed naa.5000000000000000
> sd0: 15272MB, 512 bytes/sector, 31277232 sectors, thin
> ehci0 at pci0 dev 19 function 0 "AMD Hudson-2 USB2" rev 0x39: apic 4 int 18
> usb1 at ehci0: USB revision 2.0
> uhub1 at usb1 configuration 1 interface 0 "AMD EHCI root hub" rev 2.00/1.00 addr 1
> piixpm0 at pci0 dev 20 function 0 "AMD Hudson-2 SMBus" rev 0x42: SMBus disabled
> pcib0 at pci0 dev 20 function 3 "AMD Hudson-2 LPC" rev 0x11
> sdhc0 at pci0 dev 20 function 7 "AMD Bolton SD/MMC" rev 0x01: apic 4 int 16
> sdhc0: SDHC 2.0, 63 MHz base clock
> sdmmc0 at sdhc0: 4-bit, sd high-speed, mmc high-speed, dma
> pchb2 at pci0 dev 24 function 0 "AMD AMD64 16h Link Cfg" rev 0x00
> pchb3 at pci0 dev 24 function 1 "AMD AMD64 16h Address Map" rev 0x00
> pchb4 at pci0 dev 24 function 2 "AMD AMD64 16h DRAM Cfg" rev 0x00
> km0 at pci0 dev 24 function 3 "AMD AMD64 16h Misc Cfg" rev 0x00
> pchb5 at pci0 dev 24 function 4 "AMD AMD64 16h CPU Power" rev 0x00
> pchb6 at pci0 dev 24 function 5 "AMD AMD64 16h Misc Cfg" rev 0x00
> isa0 at pcib0
> isadma0 at isa0
> com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
> com0: console
> com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
> pcppi0 at isa0 port 0x61
> spkr0 at pcppi0
> lpt0 at isa0 port 0x378/4 irq 7
> wbsio0 at isa0 port 0x2e/2: NCT5104D rev 0x52
> vmm0 at mainbus0: SVM/RVI
> uhub2 at uhub1 port 1 configuration 1 interface 0 "Advanced Micro Devices product 0x7900" rev 2.00/0.18 addr 2
> vscsi0 at root
> scsibus2 at vscsi0: 256 targets
> softraid0 at root
> scsibus3 at softraid0: 256 targets
> root on sd0a (c13267e44c837452.a) swap on sd0b dump on sd0b
> WARNING: / was not properly unmounted
> Process (pid 1) got signal 31
>
> usbdevs:
> Controller /dev/usb0:
> addr 01: 1022:0000 AMD, xHCI root hub
>      super speed, self powered, config 1, rev 1.00
>      driver: uhub0
> Controller /dev/usb1:
> addr 01: 1022:0000 AMD, EHCI root hub
>      high speed, self powered, config 1, rev 1.00
>      driver: uhub1
> addr 02: 0438:7900 Advanced Micro Devices, product 0x7900
>      high speed, self powered, config 1, rev 0.18
>      driver: uhub2
Reply | Threaded
Open this post in threaded view
|

Re: switchd segfaults

Ayaka Koshibe-2
On Fri, Mar 22, 2019 at 09:47:51AM +0000, Leon Lagodny wrote:

> Ok, it took a while for switchd to crash again. Here the output of gdb with debugging  symbols enabled.
>
> (gdb) bt full
> #0  0x00000b62ca3e7a50 in _libc_yp_first (indomain=0xb62cf99f440 "", inmap=0xb62eaf445e8 '' <repeats 200 times>..., outkey=0xb62ca3796ff, outkeylen=0x0, outval=0xd, outvallen=0x5c0) from /usr/lib/libc.so.92.5
>         ysd = (struct dom_binding *) 0xb5f00000001
>         r = Variable "r" is not available.
> (gdb) where
> #0  0x00000b62ca3e7a50 in _libc_yp_first (indomain=0xb62cf99f440 "", inmap=0xb62eaf445e8 '' <repeats 200 times>..., outkey=0xb62ca3796ff, outkeylen=0x0, outval=0xd, outvallen=0x5c0) from /usr/lib/libc.so.92.5
> #1  0x00000b62d5e28350 in ibuf_add (buf=0xb62cf99f440, data=0x0, len=1494) at /usr/src/lib/libutil/imsg-buffer.c:97
> #2  0x00000b62d5e26a2e in imsg_add (msg=0xb62cf99f440, data=Variable "data" is not available.
> ) at /usr/src/lib/libutil/imsg.c:240
> #3  0x00000b5ffe80ab56 in ofp13_packet_in (sc=0xb62cf99a4d0, con=0xb6263883c00, ih=Variable "ih" is not available.
> ) at /usr/src/usr.sbin/switchd/ofp13.c:1150
> #4  0x00000b5ffe80cb32 in ofp13_input (sc=0xb62cf99a4d0, con=0xb6263883c00, oh=0xb624549e000, ibuf=0xb626387da80) at /usr/src/usr.sbin/switchd/ofp13.c:621
> #5  0x00000b5ffe809672 in ofp_input (con=0xb6263883c00, ibuf=0xb626387da80) at /usr/src/usr.sbin/switchd/ofp.c:159
> #6  0x00000b5ffe811625 in ofrelay_input_done (con=0xb6263883c00, buf=0xb626387da80) at /usr/src/usr.sbin/switchd/ofrelay.c:282
> #7  0x00000b5ffe811157 in ofrelay_event (fd=8, event=2, arg=0xb6263883c00) at /usr/src/usr.sbin/switchd/ofrelay.c:138
> #8  0x00000b62394a7bbd in event_base_loop (base=0xb6263883400, flags=0) at /usr/src/lib/libevent/event.c:350
> #9  0x00000b5ffe803a98 in proc_run (ps=0xb62cf99a4d0, p=0xb5ffea22000, procs=0xb5ffea22180, nproc=2, run=0xb5ffe809360 <ofp_run>, arg=0x0) at /usr/src/usr.sbin/switchd/proc.c:602
> #10 0x00000b5ffe802a8b in proc_init (ps=Variable "ps" is not available.
> ) at /usr/src/usr.sbin/switchd/proc.c:260
> #11 0x00000b5ffe807660 in main (argc=5, argv=0x7f7ffffdd658) at /usr/src/usr.sbin/switchd/switchd.c:187

Hi,

This looks like a case where the switch requires switchd to supply a copy
of the packet being forwarded, but the latter doesn't set its buffer for
the packet data. Currently, this can happen if the copy of the packet
recieved from the switch is too short (source/destination pairs can't be
recovered), is non-unicast, or when switchd has to fall back to flooding
traffic.

This diff, based off of one by guenther, factors out the check for short
packets, stopping before forwarding decisions are made if the full packet
is needed by the switch. It also sets the packet buffer early for cases
where it is needed otherwise. This should prevent the above situation.

Not sure if it's excess noise, but I've also turned a few bzero's into
memset's along the way.

I've been running switchd with this diff for ~2 days without issue.


OK?


Thanks,
Ayaka

Index: switchd/ofp10.c
===================================================================
RCS file: /cvs/src/usr.sbin/switchd/ofp10.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 ofp10.c
--- switchd/ofp10.c 9 Sep 2018 14:21:32 -0000 1.20
+++ switchd/ofp10.c 30 Apr 2019 06:28:52 -0000
@@ -342,7 +342,7 @@ ofp10_packet_match(struct packet *pkt, s
 {
  struct ether_header *eh = pkt->pkt_eh;
 
- bzero(m, sizeof(*m));
+ memset(m, 0, sizeof(*m));
  m->m_wildcards = htonl(~flags);
 
  if ((flags & (OFP10_WILDCARD_DL_SRC|OFP10_WILDCARD_DL_DST)) &&
@@ -377,12 +377,17 @@ ofp10_packet_in(struct switchd *sc, stru
  if ((pin = ibuf_getdata(ibuf, sizeof(*pin))) == NULL)
  return (-1);
 
- bzero(&pkt, sizeof(pkt));
+ memset(&pkt, 0, sizeof(pkt));
  len = ntohs(pin->pin_total_len);
+
  srcport = ntohs(pin->pin_port);
 
+ if (packet_ether_input(ibuf, len, &pkt) == -1 &&
+    pin->pin_buffer_id == htonl(OFP_PKTOUT_NO_BUFFER))
+ return(-1);
+
  if (packet_input(sc, con->con_switch,
-    srcport, &dstport, ibuf, len, &pkt) == -1 ||
+    srcport, &dstport, &pkt) == -1 ||
     (dstport > OFP10_PORT_MAX &&
     dstport != OFP10_PORT_LOCAL &&
     dstport != OFP10_PORT_CONTROLLER)) {
Index: switchd/ofp13.c
===================================================================
RCS file: /cvs/src/usr.sbin/switchd/ofp13.c,v
retrieving revision 1.44
diff -u -p -u -r1.44 ofp13.c
--- switchd/ofp13.c 9 Sep 2018 14:21:32 -0000 1.44
+++ switchd/ofp13.c 30 Apr 2019 06:28:52 -0000
@@ -1029,7 +1029,7 @@ ofp13_packet_in(struct switchd *sc, stru
  if (pin->pin_reason != OFP_PKTIN_REASON_NO_MATCH)
  return (-1);
 
- bzero(&pkt, sizeof(pkt));
+ memset(&pkt, 0, sizeof(pkt));
  len = ntohs(pin->pin_total_len);
 
  /* very basic way of getting the source port */
@@ -1070,8 +1070,12 @@ ofp13_packet_in(struct switchd *sc, stru
  if (ibuf_getdata(ibuf, off) == NULL)
  return (-1);
 
+ if (packet_ether_input(ibuf, len, &pkt) == -1 &&
+    pin->pin_buffer_id == htonl(OFP_PKTOUT_NO_BUFFER))
+ return(-1);
+
  if (packet_input(sc, con->con_switch,
-    srcport, &dstport, ibuf, len, &pkt) == -1 ||
+    srcport, &dstport, &pkt) == -1 ||
     (dstport > OFP_PORT_MAX &&
     dstport != OFP_PORT_LOCAL &&
     dstport != OFP_PORT_CONTROLLER)) {
Index: switchd/packet.c
===================================================================
RCS file: /cvs/src/usr.sbin/switchd/packet.c,v
retrieving revision 1.5
diff -u -p -u -r1.5 packet.c
--- switchd/packet.c 6 Aug 2017 17:31:19 -0000 1.5
+++ switchd/packet.c 30 Apr 2019 06:28:52 -0000
@@ -50,14 +50,10 @@ packet_ether_unicast(uint8_t *ea)
 }
 
 int
-packet_input(struct switchd *sc, struct switch_control *sw, uint32_t srcport,
-    uint32_t *dstport, struct ibuf *ibuf, size_t len, struct packet *pkt)
+packet_ether_input(struct ibuf *ibuf, size_t len, struct packet *pkt)
 {
  struct ether_header *eh;
- struct macaddr *src, *dst;
 
- if (sw == NULL)
- return (-1);
  if (len < sizeof(*eh))
  return (-1);
 
@@ -66,8 +62,24 @@ packet_input(struct switchd *sc, struct
  log_debug("short packet");
  return (-1);
  }
- len -= sizeof(*eh);
 
+ pkt->pkt_eh = eh;
+ pkt->pkt_buf = (uint8_t *)eh;
+
+ return (0);
+}
+
+int
+packet_input(struct switchd *sc, struct switch_control *sw, uint32_t srcport,
+    uint32_t *dstport, struct packet *pkt)
+{
+ struct ether_header *eh;
+ struct macaddr *src, *dst;
+
+ if (sw == NULL)
+ return (-1);
+
+ eh = pkt->pkt_eh;
  if ((packet_ether_unicast(eh->ether_shost) == -1) ||
     (src = switch_learn(sc, sw, eh->ether_shost, srcport)) == NULL)
  return (-1);
@@ -85,9 +97,6 @@ packet_input(struct switchd *sc, struct
 
  if (dstport)
  *dstport = dst == NULL ? OFP_PORT_ANY : dst->mac_port;
-
- pkt->pkt_eh = eh;
- pkt->pkt_buf = (uint8_t *)eh;
 
  return (0);
 }
Index: switchd/switchd.h
===================================================================
RCS file: /cvs/src/usr.sbin/switchd/switchd.h,v
retrieving revision 1.28
diff -u -p -u -r1.28 switchd.h
--- switchd/switchd.h 22 Dec 2016 15:31:43 -0000 1.28
+++ switchd/switchd.h 30 Apr 2019 06:28:52 -0000
@@ -211,9 +211,9 @@ struct switch_connection *
  switchd_connbyaddr(struct switchd *, struct sockaddr *);
 
 /* packet.c */
+int packet_ether_input(struct ibuf *, size_t, struct packet *);
 int packet_input(struct switchd *, struct switch_control *,
-    uint32_t, uint32_t *, struct ibuf *, size_t,
-    struct packet *);
+    uint32_t, uint32_t *, struct packet *);
 
 /* switch.c */
 void switch_init(struct switchd *);