forked from Minki/linux
l2tp: add peer_offset parameter
Introduce peer_offset parameter in order to add the capability to specify two different values for payload offset on tx/rx side. If just offset is provided by userspace use it for rx side as well in order to maintain compatibility with older l2tp versions Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
820da53575
commit
f15bc54eee
@ -127,6 +127,7 @@ enum {
|
|||||||
L2TP_ATTR_UDP_ZERO_CSUM6_TX, /* flag */
|
L2TP_ATTR_UDP_ZERO_CSUM6_TX, /* flag */
|
||||||
L2TP_ATTR_UDP_ZERO_CSUM6_RX, /* flag */
|
L2TP_ATTR_UDP_ZERO_CSUM6_RX, /* flag */
|
||||||
L2TP_ATTR_PAD,
|
L2TP_ATTR_PAD,
|
||||||
|
L2TP_ATTR_PEER_OFFSET, /* u16 */
|
||||||
__L2TP_ATTR_MAX,
|
__L2TP_ATTR_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -792,7 +792,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
|
|||||||
ptr += 2 + offset;
|
ptr += 2 + offset;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ptr += session->offset;
|
ptr += session->peer_offset;
|
||||||
|
|
||||||
offset = ptr - optr;
|
offset = ptr - optr;
|
||||||
if (!pskb_may_pull(skb, offset))
|
if (!pskb_may_pull(skb, offset))
|
||||||
@ -1785,6 +1785,7 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn
|
|||||||
session->lns_mode = cfg->lns_mode;
|
session->lns_mode = cfg->lns_mode;
|
||||||
session->reorder_timeout = cfg->reorder_timeout;
|
session->reorder_timeout = cfg->reorder_timeout;
|
||||||
session->offset = cfg->offset;
|
session->offset = cfg->offset;
|
||||||
|
session->peer_offset = cfg->peer_offset;
|
||||||
session->l2specific_type = cfg->l2specific_type;
|
session->l2specific_type = cfg->l2specific_type;
|
||||||
session->l2specific_len = cfg->l2specific_len;
|
session->l2specific_len = cfg->l2specific_len;
|
||||||
session->cookie_len = cfg->cookie_len;
|
session->cookie_len = cfg->cookie_len;
|
||||||
|
@ -59,7 +59,8 @@ struct l2tp_session_cfg {
|
|||||||
int debug; /* bitmask of debug message
|
int debug; /* bitmask of debug message
|
||||||
* categories */
|
* categories */
|
||||||
u16 vlan_id; /* VLAN pseudowire only */
|
u16 vlan_id; /* VLAN pseudowire only */
|
||||||
u16 offset; /* offset to payload */
|
u16 offset; /* offset to tx payload */
|
||||||
|
u16 peer_offset; /* offset to rx payload */
|
||||||
u16 l2specific_len; /* Layer 2 specific length */
|
u16 l2specific_len; /* Layer 2 specific length */
|
||||||
u16 l2specific_type; /* Layer 2 specific type */
|
u16 l2specific_type; /* Layer 2 specific type */
|
||||||
u8 cookie[8]; /* optional cookie */
|
u8 cookie[8]; /* optional cookie */
|
||||||
@ -86,8 +87,14 @@ struct l2tp_session {
|
|||||||
int cookie_len;
|
int cookie_len;
|
||||||
u8 peer_cookie[8];
|
u8 peer_cookie[8];
|
||||||
int peer_cookie_len;
|
int peer_cookie_len;
|
||||||
u16 offset; /* offset from end of L2TP header
|
u16 offset; /* offset from end of L2TP
|
||||||
to beginning of data */
|
* header to beginning of
|
||||||
|
* tx data
|
||||||
|
*/
|
||||||
|
u16 peer_offset; /* offset from end of L2TP
|
||||||
|
* header to beginning of
|
||||||
|
* rx data
|
||||||
|
*/
|
||||||
u16 l2specific_len;
|
u16 l2specific_len;
|
||||||
u16 l2specific_type;
|
u16 l2specific_type;
|
||||||
u16 hdr_len;
|
u16 hdr_len;
|
||||||
|
@ -180,8 +180,9 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v)
|
|||||||
session->lns_mode ? "LNS" : "LAC",
|
session->lns_mode ? "LNS" : "LAC",
|
||||||
session->debug,
|
session->debug,
|
||||||
jiffies_to_msecs(session->reorder_timeout));
|
jiffies_to_msecs(session->reorder_timeout));
|
||||||
seq_printf(m, " offset %hu l2specific %hu/%hu\n",
|
seq_printf(m, " offset %hu peer_offset %hu l2specific %hu/%hu\n",
|
||||||
session->offset, session->l2specific_type, session->l2specific_len);
|
session->offset, session->peer_offset,
|
||||||
|
session->l2specific_type, session->l2specific_len);
|
||||||
if (session->cookie_len) {
|
if (session->cookie_len) {
|
||||||
seq_printf(m, " cookie %02x%02x%02x%02x",
|
seq_printf(m, " cookie %02x%02x%02x%02x",
|
||||||
session->cookie[0], session->cookie[1],
|
session->cookie[0], session->cookie[1],
|
||||||
@ -228,7 +229,8 @@ static int l2tp_dfs_seq_show(struct seq_file *m, void *v)
|
|||||||
seq_puts(m, " debug tx-pkts/bytes/errs rx-pkts/bytes/errs\n");
|
seq_puts(m, " debug tx-pkts/bytes/errs rx-pkts/bytes/errs\n");
|
||||||
seq_puts(m, " SESSION ID, peer ID, PWTYPE\n");
|
seq_puts(m, " SESSION ID, peer ID, PWTYPE\n");
|
||||||
seq_puts(m, " refcnt cnt\n");
|
seq_puts(m, " refcnt cnt\n");
|
||||||
seq_puts(m, " offset OFFSET l2specific TYPE/LEN\n");
|
seq_puts(m, " offset OFFSET peer_offset OFFSET");
|
||||||
|
seq_puts(m, " l2specific TYPE/LEN\n");
|
||||||
seq_puts(m, " [ cookie ]\n");
|
seq_puts(m, " [ cookie ]\n");
|
||||||
seq_puts(m, " [ peer cookie ]\n");
|
seq_puts(m, " [ peer cookie ]\n");
|
||||||
seq_puts(m, " config mtu/mru/rcvseq/sendseq/dataseq/lns debug reorderto\n");
|
seq_puts(m, " config mtu/mru/rcvseq/sendseq/dataseq/lns debug reorderto\n");
|
||||||
|
@ -547,9 +547,25 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tunnel->version > 2) {
|
if (tunnel->version > 2) {
|
||||||
if (info->attrs[L2TP_ATTR_OFFSET])
|
if (info->attrs[L2TP_ATTR_PEER_OFFSET]) {
|
||||||
|
struct nlattr *peer_offset;
|
||||||
|
|
||||||
|
peer_offset = info->attrs[L2TP_ATTR_PEER_OFFSET];
|
||||||
|
cfg.peer_offset = nla_get_u16(peer_offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->attrs[L2TP_ATTR_OFFSET]) {
|
||||||
cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]);
|
cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]);
|
||||||
|
|
||||||
|
/* in order to maintain compatibility with older
|
||||||
|
* versions where offset was used for both tx and
|
||||||
|
* rx side, update rx side with offset if peer_offset
|
||||||
|
* is not provided by userspace
|
||||||
|
*/
|
||||||
|
if (!info->attrs[L2TP_ATTR_PEER_OFFSET])
|
||||||
|
cfg.peer_offset = cfg.offset;
|
||||||
|
}
|
||||||
|
|
||||||
if (info->attrs[L2TP_ATTR_DATA_SEQ])
|
if (info->attrs[L2TP_ATTR_DATA_SEQ])
|
||||||
cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]);
|
cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]);
|
||||||
|
|
||||||
@ -763,6 +779,8 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 portid, u32 seq, int fl
|
|||||||
nla_put_string(skb, L2TP_ATTR_IFNAME, session->ifname)) ||
|
nla_put_string(skb, L2TP_ATTR_IFNAME, session->ifname)) ||
|
||||||
(session->offset &&
|
(session->offset &&
|
||||||
nla_put_u16(skb, L2TP_ATTR_OFFSET, session->offset)) ||
|
nla_put_u16(skb, L2TP_ATTR_OFFSET, session->offset)) ||
|
||||||
|
(session->peer_offset &&
|
||||||
|
nla_put_u16(skb, L2TP_ATTR_PEER_OFFSET, session->peer_offset)) ||
|
||||||
(session->cookie_len &&
|
(session->cookie_len &&
|
||||||
nla_put(skb, L2TP_ATTR_COOKIE, session->cookie_len,
|
nla_put(skb, L2TP_ATTR_COOKIE, session->cookie_len,
|
||||||
&session->cookie[0])) ||
|
&session->cookie[0])) ||
|
||||||
@ -903,6 +921,7 @@ static const struct nla_policy l2tp_nl_policy[L2TP_ATTR_MAX + 1] = {
|
|||||||
[L2TP_ATTR_PW_TYPE] = { .type = NLA_U16, },
|
[L2TP_ATTR_PW_TYPE] = { .type = NLA_U16, },
|
||||||
[L2TP_ATTR_ENCAP_TYPE] = { .type = NLA_U16, },
|
[L2TP_ATTR_ENCAP_TYPE] = { .type = NLA_U16, },
|
||||||
[L2TP_ATTR_OFFSET] = { .type = NLA_U16, },
|
[L2TP_ATTR_OFFSET] = { .type = NLA_U16, },
|
||||||
|
[L2TP_ATTR_PEER_OFFSET] = { .type = NLA_U16, },
|
||||||
[L2TP_ATTR_DATA_SEQ] = { .type = NLA_U8, },
|
[L2TP_ATTR_DATA_SEQ] = { .type = NLA_U8, },
|
||||||
[L2TP_ATTR_L2SPEC_TYPE] = { .type = NLA_U8, },
|
[L2TP_ATTR_L2SPEC_TYPE] = { .type = NLA_U8, },
|
||||||
[L2TP_ATTR_L2SPEC_LEN] = { .type = NLA_U8, },
|
[L2TP_ATTR_L2SPEC_LEN] = { .type = NLA_U8, },
|
||||||
|
Loading…
Reference in New Issue
Block a user