Skip to content

Commit 900631e

Browse files
j-c-hdavem330
authored andcommitted
l2tp: remove configurable payload offset
If L2TP_ATTR_OFFSET is set to a non-zero value in L2TPv3 tunnels, it results in L2TPv3 packets being transmitted which might not be compliant with the L2TPv3 RFC. This patch has l2tp ignore the offset setting and send all packets with no offset. In more detail: L2TPv2 supports a variable offset from the L2TPv2 header to the payload. The offset value is indicated by an optional field in the L2TP header. Our L2TP implementation already detects the presence of the optional offset and skips that many bytes when handling data received packets. All transmitted packets are always transmitted with no offset. L2TPv3 has no optional offset field in the L2TPv3 packet header. Instead, L2TPv3 defines optional fields in a "Layer-2 Specific Sublayer". At the time when the original L2TP code was written, there was talk at IETF of offset being implemented in a new Layer-2 Specific Sublayer. A L2TP_ATTR_OFFSET netlink attribute was added so that this offset could be configured and the intention was to allow it to be also used to set the tx offset for L2TPv2. However, no L2TPv3 offset was ever specified and the L2TP_ATTR_OFFSET parameter was forgotten about. Setting L2TP_ATTR_OFFSET results in L2TPv3 packets being transmitted with the specified number of bytes padding between L2TPv3 header and payload. This is not compliant with L2TPv3 RFC3931. This change removes the configurable offset altogether while retaining L2TP_ATTR_OFFSET for backwards compatibility. Any L2TP_ATTR_OFFSET value is ignored. Signed-off-by: James Chapman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent de3b58b commit 900631e

File tree

4 files changed

+6
-18
lines changed

4 files changed

+6
-18
lines changed

net/l2tp/l2tp_core.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -780,19 +780,16 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
780780
}
781781
}
782782

783-
/* Session data offset is handled differently for L2TPv2 and
784-
* L2TPv3. For L2TPv2, there is an optional 16-bit value in
785-
* the header. For L2TPv3, the offset is negotiated using AVPs
786-
* in the session setup control protocol.
783+
/* Session data offset is defined only for L2TPv2 and is
784+
* indicated by an optional 16-bit value in the header.
787785
*/
788786
if (tunnel->version == L2TP_HDR_VER_2) {
789787
/* If offset bit set, skip it. */
790788
if (hdrflags & L2TP_HDRFLAG_O) {
791789
offset = ntohs(*(__be16 *)ptr);
792790
ptr += 2 + offset;
793791
}
794-
} else
795-
ptr += session->offset;
792+
}
796793

797794
offset = ptr - optr;
798795
if (!pskb_may_pull(skb, offset))
@@ -1068,8 +1065,6 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf)
10681065
}
10691066
bufp += session->l2specific_len;
10701067
}
1071-
if (session->offset)
1072-
bufp += session->offset;
10731068

10741069
return bufp - optr;
10751070
}
@@ -1734,7 +1729,7 @@ void l2tp_session_set_header_len(struct l2tp_session *session, int version)
17341729
if (session->send_seq)
17351730
session->hdr_len += 4;
17361731
} else {
1737-
session->hdr_len = 4 + session->cookie_len + session->l2specific_len + session->offset;
1732+
session->hdr_len = 4 + session->cookie_len + session->l2specific_len;
17381733
if (session->tunnel->encap == L2TP_ENCAPTYPE_UDP)
17391734
session->hdr_len += 4;
17401735
}
@@ -1784,7 +1779,6 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
17841779
session->recv_seq = cfg->recv_seq;
17851780
session->lns_mode = cfg->lns_mode;
17861781
session->reorder_timeout = cfg->reorder_timeout;
1787-
session->offset = cfg->offset;
17881782
session->l2specific_type = cfg->l2specific_type;
17891783
session->l2specific_len = cfg->l2specific_len;
17901784
session->cookie_len = cfg->cookie_len;

net/l2tp/l2tp_core.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ struct l2tp_session_cfg {
5959
int debug; /* bitmask of debug message
6060
* categories */
6161
u16 vlan_id; /* VLAN pseudowire only */
62-
u16 offset; /* offset to payload */
6362
u16 l2specific_len; /* Layer 2 specific length */
6463
u16 l2specific_type; /* Layer 2 specific type */
6564
u8 cookie[8]; /* optional cookie */
@@ -86,8 +85,6 @@ struct l2tp_session {
8685
int cookie_len;
8786
u8 peer_cookie[8];
8887
int peer_cookie_len;
89-
u16 offset; /* offset from end of L2TP header
90-
to beginning of data */
9188
u16 l2specific_len;
9289
u16 l2specific_type;
9390
u16 hdr_len;

net/l2tp/l2tp_debugfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v)
180180
session->lns_mode ? "LNS" : "LAC",
181181
session->debug,
182182
jiffies_to_msecs(session->reorder_timeout));
183-
seq_printf(m, " offset %hu l2specific %hu/%hu\n",
184-
session->offset, session->l2specific_type, session->l2specific_len);
183+
seq_printf(m, " offset 0 l2specific %hu/%hu\n",
184+
session->l2specific_type, session->l2specific_len);
185185
if (session->cookie_len) {
186186
seq_printf(m, " cookie %02x%02x%02x%02x",
187187
session->cookie[0], session->cookie[1],

net/l2tp/l2tp_netlink.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,6 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
547547
}
548548

549549
if (tunnel->version > 2) {
550-
if (info->attrs[L2TP_ATTR_OFFSET])
551-
cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]);
552-
553550
if (info->attrs[L2TP_ATTR_DATA_SEQ])
554551
cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]);
555552

0 commit comments

Comments
 (0)