Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: MIPS support for packetbeat #4522

Closed
brianredbeard opened this issue Jun 18, 2017 · 20 comments
Closed

RFE: MIPS support for packetbeat #4522

brianredbeard opened this issue Jun 18, 2017 · 20 comments
Labels
enhancement needs_team Indicates that the issue/PR needs a Team:* label Packetbeat Stalled

Comments

@brianredbeard
Copy link

As an administrator, I run many different chip architectures. The currently support for arm64 with Packetbeat is fantastic, but I would be over the moon if Packetbeat would run on MIPS/MIPS64. The reason for this is allowing Packetbeat to execute directly on some of my routers for traffic introspection.

For reference:

$ cat /proc/cpuinfo
system type		: MT7621
machine			: Unknown
processor		: 0
cpu model		: MIPS 1004Kc V2.15
BogoMIPS		: 583.68
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa			: mips1 mips2 mips32r1 mips32r2
ASEs implemented	: mips16 dsp mt
shadow register sets	: 1
kscratch registers	: 0
core			: 0
VPE			: 0
VCED exceptions		: not available
VCEI exceptions		: not available
...
$uname -m
mips
$ cat /proc/cpuinfo
system type		: UBNT_E200
machine			: Unknown
processor		: 0
cpu model		: Cavium Octeon II V0.1
BogoMIPS		: 2000.00
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 128
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
isa			: mips1 mips2 mips3 mips4 mips5 mips64r2
ASEs implemented	:
shadow register sets	: 1
kscratch registers	: 3
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available
...
$ uname -m
mips64

File under request for enhancement.

@markwalkom
Copy link
Contributor

This would be super useful for my networking kit (at home).

If anyone else comes across this, I have been compiling file+metricbeat for MIPS64 via https://github.com/caglar10ur/elk-usg.

@zbikmarc
Copy link

Any chance for this?

Other beats are working but most useful for routers and other network gear can not be compiled because of failed constraints:

~/go/src/github.com/elastic/beats/packetbeat# GOOS=linux GOARCH=mips64 go build -o ~/elastic/packetbeat
sniffer/afpacket_linux.go:9:2: build constraints exclude all Go files in /root/go/src/github.com/elastic/beats/vendor/github.com/tsg/gopacket/afpacket

@andrewkroh
Copy link
Member

Related: #7388

That PR provides a way to build Packetbeat for mips, mipsle, mips64, and mips64le (among other arches). It has some snapshots builds linked for testing purposes. See https://github.com/elastic/beats/files/2122012/snapshot-urls.txt (temporary).

@brianredbeard
Copy link
Author

Tested + working on MIPSLE

@jamesspi
Copy link
Contributor

jamesspi commented Sep 3, 2018

Can't seem to get it to work on mips64.

@andrewkroh
Copy link
Member

@jamesspi Could you please provide more background on the problem you are having. Is the issue that you cannot build Packetbeat or is it that you cannot run it? What's the error?

You can download snapshot builds for linux/mips64 from Jenkins.

@jamesspi
Copy link
Contributor

jamesspi commented Sep 7, 2018

@andrewkroh I tried running one of the precompiled builds and it just fails with "cannot run executable".

@andrewkroh
Copy link
Member

@jamesspi I wonder if it's an issue with the architecture of the binary. "mips64" in Go is a big-endian. The binary is dynamically linked due to the use of cgo so it expects a 64-bit userspace (some mips machines have 64-bit kernels but have 32-bit userspace).

$ file ~/Downloads/packetbeat-7.0.0-alpha1-SNAPSHOT-linux-mips64/packetbeat /Users/akroh/Downloads/packetbeat-7.0.0-alpha1-SNAPSHOT-linux-mips64/packetbeat: ELF 64-bit MSB executable, MIPS, MIPS64 rel2 version 1 (SYSV), dynamically linked, interpreter /lib64/ld.so.1, BuildID[sha1]=3030e2193a556ffd7b77f82790fe7f5ee6cb0b86, for GNU/Linux 3.2.0, with debug_info, not stripped

So I'd check a few things:

  • ldd packetbeat
  • uname -a
  • file packetbeat
  • cat /proc/cpuinfo

@jamesspi
Copy link
Contributor

Hey @andrewkroh , sorry I haven't gotten back to you, been on the road.

I'll give this a go and let you know - thanks a mill.

@jamesspi
Copy link
Contributor

Hey @andrewkroh , here is the output:

root@MainFirewall:/home/James/packetbeat-7.0.0-alpha1-SNAPSHOT-linux-mips64# ldd packetbeat not a dynamic executable

root@MainFirewall:/home/James/packetbeat-7.0.0-alpha1-SNAPSHOT-linux-mips64# uname -a Linux MainFirewall 3.10.20-UBNT #1 SMP Fri Nov 3 16:28:23 MDT 2017 mips64 GNU/Linux

root@MainFirewall:/home/James/packetbeat-7.0.0-alpha1-SNAPSHOT-linux-mips64# cat /proc/cpuinfo  
system type             : UBNT_E220
machine                 : Unknown
processor               : 0
cpu model               : Cavium Octeon II V0.1
BogoMIPS                : 2000.00
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 128
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
isa                     : mips1 mips2 mips3 mips4 mips5 mips64r2
ASEs implemented        :
shadow register sets    : 1
kscratch registers      : 3
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available

processor               : 1
cpu model               : Cavium Octeon II V0.1
BogoMIPS                : 2000.00
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 128
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 2, address/irw mask: [0x0ffc, 0x0ffb]
isa                     : mips1 mips2 mips3 mips4 mips5 mips64r2
ASEs implemented        :
shadow register sets    : 1
kscratch registers      : 3
core                    : 1
VCED exceptions         : not available
VCEI exceptions         : not available

file isn't available on the OS.

Thanks!
James

@andrewkroh
Copy link
Member

@jamesspi What about the user-space setup? Check the "Architecture" column in dpkg -l. You might need mips packages instead of mips64.

@jamesspi
Copy link
Contributor

@andrewkroh - Bingo, that worked. Thanks a mill!

@markwalkom
Copy link
Contributor

It'd be awesome to widen this enhancement to include all of our beats for MIPS* :)

@mehrenreich
Copy link

Hi @jamesspi,

it's been a while, but do you remember where you found the 32-bit mips files? I can't find them:(

Thanks!

@jamesspi
Copy link
Contributor

Hi @slackware666 - Try following this guide to compile in mips :) https://github.com/caglar10ur/elk-usg/

@andrewkroh
Copy link
Member

andrewkroh commented Apr 23, 2019

A mips package can be produced directly from the beats packaging build provided you have Go and Docker setup.

go get -d github.com/elastic/beats # Clone beats repo into GOPATH.
cd $GOPATH/src/github.com/elastic/beats/packetbeat
git checkout v7.3.2 # Build from some release tag.
PLATFORMS="+all linux/mips" make release
ls -la build/distributions

@maxviper
Copy link

Hi @andrewkroh
Can you elaborate on "provided you have Go and Docker setup."
I do have docker and go on my MacBook. I'm trying to get packetbeat for MIPS and ARM.
The above doesn't work. Can you help me forward?

@andrewkroh
Copy link
Member

I changed make package to make release in the above example.

$ go version
go version go1.12.9 darwin/amd64

$ cd $GOPATH/src/github.com/elastic/beats/packetbeat
$ git checkout v7.3.2
HEAD is now at 5b046c5a9 [7.3] Fix typos + add CHANGELOG (#13481) (#13510)

$ PLATFORMS="+all linux/mips" make release
2019/09/27 00:43:59 Found Elastic Beats dir at /Users/akroh/go/src/github.com/elastic/beats
Generated fields.yml for packetbeat to /Users/akroh/go/src/github.com/elastic/beats/packetbeat/fields.yml
No fields files for module applayer
No fields files for module tcp
No fields files for module udp
Generated fields.yml for packetbeat to /Users/akroh/go/src/github.com/elastic/beats/packetbeat/fields.yml
>> Building packetbeat.yml for linux/amd64
>> Building packetbeat.reference.yml for linux/amd64
>> Building packetbeat.docker.yml for linux/amd64
2019/09/27 00:44:01 Found Elastic Beats dir at /Users/akroh/go/src/github.com/elastic/beats
>> buildGoDaemon: Building for linux/mips
>> golangCrossBuild: Building for linux/mips
>> golangCrossBuild: Building for linux/mips
>> Building using: cmd='build/mage-linux-amd64 golangCrossBuild', env=[CC=mips-linux-gnu-gcc, CXX=mips-linux-gnu-g++, GOARCH=mips, GOARM=, GOOS=linux, PLATFORM_ID=linux-mips]
>> Building using: cmd='../../packetbeat/build/mage-linux-amd64 golangCrossBuild', env=[CC=mips-linux-gnu-gcc, CXX=mips-linux-gnu-g++, GOARCH=mips, GOARM=, GOOS=linux, PLATFORM_ID=linux-mips]
2019/09/27 04:44:04 Found Elastic Beats dir at /go/src/github.com/elastic/beats
2019/09/27 04:44:04 Found Elastic Beats dir at /go/src/github.com/elastic/beats
>> Building using: cmd='build/mage-linux-amd64 buildGoDaemon', env=[CC=mips-linux-gnu-gcc, CXX=mips-linux-gnu-g++, GOARCH=mips, GOARM=, GOOS=linux, PLATFORM_ID=linux-mips]
2019/09/27 04:44:05 Found Elastic Beats dir at /go/src/github.com/elastic/beats
/tmp/ccpnThjx.o: In function `main':
god.c:(.text+0x494): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
god.c:(.text+0x3dc): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
configure: WARNING: using cross tools not prefixed with host triplet
configure: WARNING: using cross tools not prefixed with host triplet
grammar.y: warning: 38 shift/reduce conflicts [-Wconflicts-sr]
grammar.y: warning: 38 shift/reduce conflicts [-Wconflicts-sr]
Updated 1 path from the index
Updated 0 paths from the index
>> Building build/package/packetbeat-oss-linux-mips.tar.gz/packetbeat.reference.yml for linux/mips
>> Building build/package/packetbeat-oss-linux-mips.tar.gz/packetbeat.yml for linux/mips
>> Building build/package/packetbeat-oss-linux-mips.deb/packetbeat.yml for linux/mips
>> Building build/package/packetbeat-oss-linux-mips.deb/packetbeat.reference.yml for linux/mips
>> Building build/package/packetbeat-linux-mips.tar.gz/packetbeat.reference.yml for linux/mips
>> Building build/package/packetbeat-linux-mips.tar.gz/packetbeat.yml for linux/mips
>> Building build/package/packetbeat-linux-mips.deb/packetbeat.reference.yml for linux/mips
>> Building build/package/packetbeat-linux-mips.deb/packetbeat.yml for linux/mips
>> package: Building packetbeat type=deb for platform=linux/mips
>> package: Building packetbeat-oss type=tar.gz for platform=linux/mips
>> package: Building packetbeat type=tar.gz for platform=linux/mips
>> package: Building packetbeat-oss type=deb for platform=linux/mips
>> Testing package contents
package ran for 1m36.620261484s

$ ls -la build/distributions/
total 147640
drwxr-xr-x  10 akroh  staff       320 Sep 27 00:45 .
drwxr-xr-x  10 akroh  staff       320 Sep 27 00:45 ..
-rw-r--r--   1 akroh  staff  18303585 Sep 27 00:45 packetbeat-7.3.2-linux-mips.tar.gz
-rw-r--r--   1 akroh  staff       164 Sep 27 00:45 packetbeat-7.3.2-linux-mips.tar.gz.sha512
-rw-r--r--@  1 akroh  staff  18819164 Sep 27 00:45 packetbeat-7.3.2-mips.deb
-rw-r--r--   1 akroh  staff       155 Sep 27 00:45 packetbeat-7.3.2-mips.deb.sha512
-rw-r--r--   1 akroh  staff  18179865 Sep 27 00:45 packetbeat-oss-7.3.2-linux-mips.tar.gz
-rw-r--r--   1 akroh  staff       168 Sep 27 00:45 packetbeat-oss-7.3.2-linux-mips.tar.gz.sha512
-rw-r--r--@  1 akroh  staff  18692984 Sep 27 00:45 packetbeat-oss-7.3.2-mips.deb
-rw-r--r--   1 akroh  staff       159 Sep 27 00:45 packetbeat-oss-7.3.2-mips.deb.sha512

@botelastic
Copy link

botelastic bot commented Aug 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@botelastic botelastic bot added Stalled needs_team Indicates that the issue/PR needs a Team:* label labels Aug 27, 2020
@botelastic
Copy link

botelastic bot commented Aug 27, 2020

This issue doesn't have a Team:<team> label.

@botelastic botelastic bot closed this as completed Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs_team Indicates that the issue/PR needs a Team:* label Packetbeat Stalled
Projects
None yet
Development

No branches or pull requests

8 participants