Skip to content

Commit

Permalink
broker: Allow ports to be re-used
Browse files Browse the repository at this point in the history
The kernel requires each L2TPv3 tunnel to have it's own socket. Since we
would like to have all connections go through the same port we need to
allow port reusal.

Signed-off-by: Felix Kaechele <felix@kaechele.ca>
  • Loading branch information
kaechele committed Jan 2, 2020
1 parent 0b26882 commit e65e730
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions broker/src/tunneldigger_broker/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

from . import protocol

# Socket options.
SO_BINDTODEVICE = 25

# Logger.
logger = logging.getLogger("tunneldigger.network")

Expand All @@ -35,8 +32,9 @@ def __init__(self, address, interface):
"""

self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, interface.encode('utf-8'))
self.socket.bind(address)
self.socket.setsockopt(socket.SOL_SOCKET, SO_BINDTODEVICE, interface.encode('utf-8'))

self.address = address
self.interface = interface
Expand Down

0 comments on commit e65e730

Please sign in to comment.