Skip to content

Commit

Permalink
Use Tunnel ID also as Session ID
Browse files Browse the repository at this point in the history
The Session ID cannot be hardcoded as 1 since it needs to be unique
across all tunnels.

Signed-off-by: Felix Kaechele <felix@kaechele.ca>
  • Loading branch information
kaechele committed Oct 15, 2017
1 parent ba52f6a commit d2511d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions broker/src/tunneldigger_broker/tunnel.py
Expand Up @@ -110,7 +110,7 @@ def setup_tunnel(self):
self.broker.netlink.tunnel_create(self.tunnel_id, self.remote_tunnel_id, self.socket.fileno())

# Create a pseudowire L2TP session over the tunnel.
self.broker.netlink.session_create(self.tunnel_id, 1, 1, self.get_session_name(1))
self.broker.netlink.session_create(self.tunnel_id, self.tunnel_id, 1, self.get_session_name(self.tunnel_id))
except l2tp.L2TPTunnelExists:
self.socket.close()
raise
Expand Down Expand Up @@ -188,7 +188,7 @@ def setup_tunnel(self):
'session.up',
self.tunnel_id,
1,
self.get_session_name(1),
self.get_session_name(self.tunnel_id),
self.tunnel_mtu,
self.endpoint[0],
self.endpoint[1],
Expand Down Expand Up @@ -236,7 +236,7 @@ def update_mtu(self, initial=False):

# Alter tunnel MTU.
try:
interface_name = (self.get_session_name(1) + '\x00' * 16)[:16]
interface_name = (self.get_session_name(self.tunnel_id) + '\x00' * 16)[:16]
data = struct.pack("16si", interface_name, self.tunnel_mtu)
fcntl.ioctl(self.socket, SIOCSIFMTU, data)
except IOError:
Expand All @@ -250,7 +250,7 @@ def update_mtu(self, initial=False):
'session.mtu-changed',
self.tunnel_id,
1,
self.get_session_name(1),
self.get_session_name(self.tunnel_id),
old_tunnel_mtu,
self.tunnel_mtu,
self.uuid,
Expand Down Expand Up @@ -284,7 +284,7 @@ def close(self, reason=protocol.ERROR_REASON_UNDEFINED):
'session.pre-down',
self.tunnel_id,
1,
self.get_session_name(1),
self.get_session_name(self.tunnel_id),
self.tunnel_mtu,
self.endpoint[0],
self.endpoint[1],
Expand All @@ -299,7 +299,7 @@ def close(self, reason=protocol.ERROR_REASON_UNDEFINED):
'session.down',
self.tunnel_id,
1,
self.get_session_name(1),
self.get_session_name(self.tunnel_id),
self.tunnel_mtu,
self.endpoint[0],
self.endpoint[1],
Expand Down
2 changes: 1 addition & 1 deletion client/l2tp_client.c
Expand Up @@ -905,7 +905,7 @@ int context_setup_tunnel(l2tp_context *ctx, uint32_t peer_tunnel_id)

nla_put_u32(msg, L2TP_ATTR_CONN_ID, ctx->tunnel_id);
nla_put_u32(msg, L2TP_ATTR_SESSION_ID, 1);
nla_put_u32(msg, L2TP_ATTR_PEER_SESSION_ID, 1);
nla_put_u32(msg, L2TP_ATTR_PEER_SESSION_ID, peer_tunnel_id);
nla_put_u16(msg, L2TP_ATTR_PW_TYPE, L2TP_PWTYPE_ETH);
nla_put_string(msg, L2TP_ATTR_IFNAME, ctx->tunnel_iface);

Expand Down

0 comments on commit d2511d4

Please sign in to comment.