1

How do I set the socket options on a raw socket to have QDISC_BYPASS enabled? I saw examples in C but wasn't able to understand clearly how to implement it in Python. I constructed the socket with AF_PACKET and SOCK_RAW settings.

I understand that I need to use socket.setsockopt() method but I'm not sure how to call it correctly in this case.

Jongware
  • 22,200
  • 8
  • 54
  • 100
tt_Gantz
  • 2,786
  • 3
  • 23
  • 43

1 Answers1

3

Figured this out myself. You need linux kernel 3.14 or higher installed for it to work

sock.setsockopt(263, 20, 0);

263 (int) is a reference to SOL_PACKET

20 (int) is a reference to QDISC_BYPASS

I wrote out the numbers in case they are not defined in your socket module (i.e. socket.SOL_PACKET doesn't exist)

tt_Gantz
  • 2,786
  • 3
  • 23
  • 43