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

afpacket: Fix support for 32-bit x86 arch #720

Closed
wants to merge 1 commit into from

Conversation

adriansr
Copy link

@adriansr adriansr commented Oct 18, 2019

afpacket uses syscalls unix.SYS_GETSOCKOPT and unix.SYS_SETSOCKOPT when it needs to call [gs]etsockopt() passing a raw pointer. This doesn't work for 32-bit x86 platforms as there's no such syscall, resulting in:

setsockopt packet_rx_ring: function not implemented
unix.Syscall(unix.SYS_GETSOCKOPT[=366],...) = 38 // ENOSYS

The correct way to call [gs]etsockopt() in this platform is to use the SYS_SOCKETCALL syscall with the right call parameter.

This patch refactors the raw [gs]etsockopt() calls in afpacket to use unix.GetsockoptString and unix.SetsockoptString so that it relies on Go runtime to call the appropriate syscall.

@googlebot
Copy link
Collaborator

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@adriansr
Copy link
Author

@googlebot I signed it!

@adriansr
Copy link
Author

@googlebot I signed it!

afpacket uses syscalls unix.SYS_GETSOCKOPT and unix.SYS_SETSOCKOPT
when it needs to call [gs]etsockopt() passing a raw pointer. This
doesn't work for 32-bit x86 platforms as there's no such syscall,
resulting in:

   setsockopt packet_rx_ring: function not implemented

   unix.Syscall(unix.SYS_GETSOCKOPT[=366],...) = 38 // ENOSYS

The correct way to call [gs]etsockopt() in this platform is to use
the SYS_SOCKETCALL syscall with the right call parameter.

This patch refactors the raw [gs]etsockopt() calls in afpacket to use
unix.GetsockoptString and unix.SetsockoptString so that it relies on
Go runtime to call the appropriate syscall.
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@adriansr
Copy link
Author

@notti can I get a review? Sorry for the ping :)

adriansr added a commit to adriansr/beats that referenced this pull request Mar 27, 2020
This replaces github.com/google/gopacket with
github.com/adriansr/gopacket which includes a fix to make af_packet work
on 32bit x86.

This patched version was already vendored but lost during the migration
to Go modules.

This patch is on review at google/gopacket#720
adriansr added a commit to elastic/beats that referenced this pull request Mar 30, 2020
This replaces github.com/google/gopacket with
github.com/adriansr/gopacket which includes a fix to make af_packet work
on 32bit x86.

This patched version was already vendored but lost during the migration
to Go modules.

This patch is on review at google/gopacket#720
adriansr added a commit to adriansr/beats that referenced this pull request Mar 30, 2020
This replaces github.com/google/gopacket with
github.com/adriansr/gopacket which includes a fix to make af_packet work
on 32bit x86.

This patched version was already vendored but lost during the migration
to Go modules.

This patch is on review at google/gopacket#720

(cherry picked from commit 002b9c5)
adriansr added a commit to adriansr/beats that referenced this pull request Mar 30, 2020
This replaces github.com/google/gopacket with
github.com/adriansr/gopacket which includes a fix to make af_packet work
on 32bit x86.

This patched version was already vendored but lost during the migration
to Go modules.

This patch is on review at google/gopacket#720

(cherry picked from commit 002b9c5)
adriansr added a commit to elastic/beats that referenced this pull request Apr 7, 2020
This replaces github.com/google/gopacket with
github.com/adriansr/gopacket which includes a fix to make af_packet work
on 32bit x86.

This patched version was already vendored but lost during the migration
to Go modules.

This patch is on review at google/gopacket#720

(cherry picked from commit 002b9c5)
mikemadden42 pushed a commit to elastic/beats that referenced this pull request Apr 8, 2020
This replaces github.com/google/gopacket with
github.com/adriansr/gopacket which includes a fix to make af_packet work
on 32bit x86.

This patched version was already vendored but lost during the migration
to Go modules.

This patch is on review at google/gopacket#720

(cherry picked from commit 002b9c5)
@adriansr adriansr closed this Apr 26, 2023
leweafan pushed a commit to leweafan/beats that referenced this pull request Apr 28, 2023
This replaces github.com/google/gopacket with
github.com/adriansr/gopacket which includes a fix to make af_packet work
on 32bit x86.

This patched version was already vendored but lost during the migration
to Go modules.

This patch is on review at google/gopacket#720

(cherry picked from commit 7a65724)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants