Skip to content

Commit 81487bf

Browse files
committed
Merge branch 'l2tp-next'
Lorenzo Bianconi says: ==================== l2tp: fix offset/peer_offset conf parameters This patchset add peer_offset configuration parameter in order to specify two different values for payload offset on tx/rx side. Moreover fix missing print session offset info ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 9f30e5c + f15bc54 commit 81487bf

File tree

5 files changed

+40
-8
lines changed

5 files changed

+40
-8
lines changed

include/uapi/linux/l2tp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ enum {
127127
L2TP_ATTR_UDP_ZERO_CSUM6_TX, /* flag */
128128
L2TP_ATTR_UDP_ZERO_CSUM6_RX, /* flag */
129129
L2TP_ATTR_PAD,
130+
L2TP_ATTR_PEER_OFFSET, /* u16 */
130131
__L2TP_ATTR_MAX,
131132
};
132133

net/l2tp/l2tp_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
792792
ptr += 2 + offset;
793793
}
794794
} else
795-
ptr += session->offset;
795+
ptr += session->peer_offset;
796796

797797
offset = ptr - optr;
798798
if (!pskb_may_pull(skb, offset))
@@ -1785,6 +1785,7 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
17851785
session->lns_mode = cfg->lns_mode;
17861786
session->reorder_timeout = cfg->reorder_timeout;
17871787
session->offset = cfg->offset;
1788+
session->peer_offset = cfg->peer_offset;
17881789
session->l2specific_type = cfg->l2specific_type;
17891790
session->l2specific_len = cfg->l2specific_len;
17901791
session->cookie_len = cfg->cookie_len;

net/l2tp/l2tp_core.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ 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 */
62+
u16 offset; /* offset to tx payload */
63+
u16 peer_offset; /* offset to rx payload */
6364
u16 l2specific_len; /* Layer 2 specific length */
6465
u16 l2specific_type; /* Layer 2 specific type */
6566
u8 cookie[8]; /* optional cookie */
@@ -86,8 +87,14 @@ struct l2tp_session {
8687
int cookie_len;
8788
u8 peer_cookie[8];
8889
int peer_cookie_len;
89-
u16 offset; /* offset from end of L2TP header
90-
to beginning of data */
90+
u16 offset; /* offset from end of L2TP
91+
* header to beginning of
92+
* tx data
93+
*/
94+
u16 peer_offset; /* offset from end of L2TP
95+
* header to beginning of
96+
* rx data
97+
*/
9198
u16 l2specific_len;
9299
u16 l2specific_type;
93100
u16 hdr_len;

net/l2tp/l2tp_debugfs.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ 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 %hu peer_offset %hu l2specific %hu/%hu\n",
184+
session->offset, session->peer_offset,
185+
session->l2specific_type, session->l2specific_len);
185186
if (session->cookie_len) {
186187
seq_printf(m, " cookie %02x%02x%02x%02x",
187188
session->cookie[0], session->cookie[1],
@@ -228,7 +229,8 @@ static int l2tp_dfs_seq_show(struct seq_file *m, void *v)
228229
seq_puts(m, " debug tx-pkts/bytes/errs rx-pkts/bytes/errs\n");
229230
seq_puts(m, " SESSION ID, peer ID, PWTYPE\n");
230231
seq_puts(m, " refcnt cnt\n");
231-
seq_puts(m, " offset OFFSET l2specific TYPE/LEN\n");
232+
seq_puts(m, " offset OFFSET peer_offset OFFSET");
233+
seq_puts(m, " l2specific TYPE/LEN\n");
232234
seq_puts(m, " [ cookie ]\n");
233235
seq_puts(m, " [ peer cookie ]\n");
234236
seq_puts(m, " config mtu/mru/rcvseq/sendseq/dataseq/lns debug reorderto\n");

net/l2tp/l2tp_netlink.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,25 @@ 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])
550+
if (info->attrs[L2TP_ATTR_PEER_OFFSET]) {
551+
struct nlattr *peer_offset;
552+
553+
peer_offset = info->attrs[L2TP_ATTR_PEER_OFFSET];
554+
cfg.peer_offset = nla_get_u16(peer_offset);
555+
}
556+
557+
if (info->attrs[L2TP_ATTR_OFFSET]) {
551558
cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]);
552559

560+
/* in order to maintain compatibility with older
561+
* versions where offset was used for both tx and
562+
* rx side, update rx side with offset if peer_offset
563+
* is not provided by userspace
564+
*/
565+
if (!info->attrs[L2TP_ATTR_PEER_OFFSET])
566+
cfg.peer_offset = cfg.offset;
567+
}
568+
553569
if (info->attrs[L2TP_ATTR_DATA_SEQ])
554570
cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]);
555571

@@ -761,6 +777,10 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 portid, u32 seq, int fl
761777

762778
if ((session->ifname[0] &&
763779
nla_put_string(skb, L2TP_ATTR_IFNAME, session->ifname)) ||
780+
(session->offset &&
781+
nla_put_u16(skb, L2TP_ATTR_OFFSET, session->offset)) ||
782+
(session->peer_offset &&
783+
nla_put_u16(skb, L2TP_ATTR_PEER_OFFSET, session->peer_offset)) ||
764784
(session->cookie_len &&
765785
nla_put(skb, L2TP_ATTR_COOKIE, session->cookie_len,
766786
&session->cookie[0])) ||
@@ -901,6 +921,7 @@ static const struct nla_policy l2tp_nl_policy[L2TP_ATTR_MAX + 1] = {
901921
[L2TP_ATTR_PW_TYPE] = { .type = NLA_U16, },
902922
[L2TP_ATTR_ENCAP_TYPE] = { .type = NLA_U16, },
903923
[L2TP_ATTR_OFFSET] = { .type = NLA_U16, },
924+
[L2TP_ATTR_PEER_OFFSET] = { .type = NLA_U16, },
904925
[L2TP_ATTR_DATA_SEQ] = { .type = NLA_U8, },
905926
[L2TP_ATTR_L2SPEC_TYPE] = { .type = NLA_U8, },
906927
[L2TP_ATTR_L2SPEC_LEN] = { .type = NLA_U8, },

0 commit comments

Comments
 (0)