On 19-03-08 14:03:29, Stuart Henderson wrote: > - sysutils/beats/packetbeat is also broken, not sure how to fix that, > maybe some vendored thing is in need of an update > > cd > /usr/obj/ports/packetbeat-6.4.3/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap > CGO_LDFLAGS='"-g" "-O2" "-lpcap"' /usr/local/go/pkg/tool/openbsd_amd64/cgo > -objdir $WORK/b354/ -importpath > github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap -- -I > $WORK/b354/ -g -O2 ./pcap.go ./pcap_poll_common.go > # github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap > /usr/obj/ports/packetbeat-6.4.3/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap/pcap.go:173:7: > identifier "_Ctype_struct_bpf_program" may conflict with identifiers > generated by cgo > /usr/obj/ports/packetbeat-6.4.3/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap/pcap.go:385:13: > identifier "_Ctype_struct_pcap_stat" may conflict with identifiers generated > by cgo > /usr/obj/ports/packetbeat-6.4.3/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap/pcap.go:446:10: > identifier "_Ctype_struct_bpf_program" may conflict with identifiers > generated by cgo > /usr/obj/ports/packetbeat-6.4.3/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap/pcap.go:489:21: > identifier "_Ctype_struct_bpf_program" may conflict with identifiers > generated by cgo > /usr/obj/ports/packetbeat-6.4.3/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap/pcap.go:552:34: > identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated > by cgo > /usr/obj/ports/packetbeat-6.4.3/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap/pcap.go:555:56: > identifier "_Ctype_struct_pcap_addr" may conflict with identifiers generated > by cgo > /usr/obj/ports/packetbeat-6.4.3/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/pcap/pcap.go:821:13: > identifier "_Ctype_struct_pcap_pkthdr" may conflict with identifiers > generated by cgo
Yeah, they're doing it wrong (the code should be using C. rather than _Ctype_, which is enforced in Go 1.12)... ok? Index: patches/patch-vendor_github_com_tsg_gopacket_pcap_pcap_go =================================================================== RCS file: patches/patch-vendor_github_com_tsg_gopacket_pcap_pcap_go diff -N patches/patch-vendor_github_com_tsg_gopacket_pcap_pcap_go --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-vendor_github_com_tsg_gopacket_pcap_pcap_go 12 Mar 2019 16:43:28 -0000 @@ -0,0 +1,65 @@ +$OpenBSD$ + +Use cgo correctly - this is enforced by Go 1.12. + +Index: vendor/github.com/tsg/gopacket/pcap/pcap.go +--- vendor/github.com/tsg/gopacket/pcap/pcap.go.orig ++++ vendor/github.com/tsg/gopacket/pcap/pcap.go +@@ -170,7 +170,7 @@ type InterfaceAddress struct { + // BPF is a compiled filter program, useful for offline packet matching. + type BPF struct { + orig string +- bpf _Ctype_struct_bpf_program // takes a finalizer, not overriden by outsiders ++ bpf C.struct_bpf_program // takes a finalizer, not overriden by outsiders + } + + // BlockForever, when passed into OpenLive/SetTimeout, causes it to block forever +@@ -382,7 +382,7 @@ func (p *Handle) Error() error { + + // Stats returns statistics on the underlying pcap handle. + func (p *Handle) Stats() (stat *Stats, err error) { +- var cstats _Ctype_struct_pcap_stat ++ var cstats C.struct_pcap_stat + if -1 == C.pcap_stats(p.cptr, &cstats) { + return nil, p.Error() + } +@@ -443,7 +443,7 @@ func (p *Handle) SetBPFFilter(expr string) (err error) + } + } + +- var bpf _Ctype_struct_bpf_program ++ var bpf C.struct_bpf_program + cexpr := C.CString(expr) + defer C.free(unsafe.Pointer(cexpr)) + +@@ -486,7 +486,7 @@ func (b *BPF) String() string { + } + + // BPF returns the compiled BPF program. +-func (b *BPF) BPF() _Ctype_struct_bpf_program { ++func (b *BPF) BPF() C.struct_bpf_program { + return b.bpf + } + +@@ -549,10 +549,10 @@ func FindAllDevs() (ifs []Interface, err error) { + return + } + +-func findalladdresses(addresses *_Ctype_struct_pcap_addr) (retval []InterfaceAddress) { ++func findalladdresses(addresses *C.struct_pcap_addr) (retval []InterfaceAddress) { + // TODO - make it support more than IPv4 and IPv6? + retval = make([]InterfaceAddress, 0, 1) +- for curaddr := addresses; curaddr != nil; curaddr = (*_Ctype_struct_pcap_addr)(curaddr.next) { ++ for curaddr := addresses; curaddr != nil; curaddr = (*C.struct_pcap_addr)(curaddr.next) { + var a InterfaceAddress + var err error + // In case of a tun device on Linux the link layer has no curaddr.addr. +@@ -818,7 +818,7 @@ func (h *Handle) NewDumper(file string) (dumper *Dumpe + // Writes a packet to the file. The return values of ReadPacketData + // can be passed to this function as arguments. + func (d *Dumper) WritePacketData(data []byte, ci gopacket.CaptureInfo) (err error) { +- var pkthdr _Ctype_struct_pcap_pkthdr ++ var pkthdr C.struct_pcap_pkthdr + pkthdr.caplen = C.bpf_u_int32(ci.CaptureLength) + pkthdr.len = C.bpf_u_int32(ci.Length) +