diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2017-12-22 09:10:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-12-27 12:11:51 -0500 |
commit | f15bc54eeecd86dfba3885aab839cd1f45172a38 (patch) | |
tree | b0ce5e53ca229d324ba653f64b9cc4ac34dd8e4b /net/l2tp | |
parent | 820da5357572715c6235ba3b3daa2d5b43a1198f (diff) |
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>
Diffstat (limited to 'net/l2tp')
-rw-r--r-- | net/l2tp/l2tp_core.c | 3 | ||||
-rw-r--r-- | net/l2tp/l2tp_core.h | 13 | ||||
-rw-r--r-- | net/l2tp/l2tp_debugfs.c | 8 | ||||
-rw-r--r-- | net/l2tp/l2tp_netlink.c | 21 |
4 files changed, 37 insertions, 8 deletions
diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 115918ad8eca..6ff64717da1e 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c | |||
@@ -792,7 +792,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, | |||
792 | ptr += 2 + offset; | 792 | ptr += 2 + offset; |
793 | } | 793 | } |
794 | } else | 794 | } else |
795 | ptr += session->offset; | 795 | ptr += session->peer_offset; |
796 | 796 | ||
797 | offset = ptr - optr; | 797 | offset = ptr - optr; |
798 | if (!pskb_may_pull(skb, offset)) | 798 | if (!pskb_may_pull(skb, offset)) |
@@ -1785,6 +1785,7 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn | |||
1785 | session->lns_mode = cfg->lns_mode; | 1785 | session->lns_mode = cfg->lns_mode; |
1786 | session->reorder_timeout = cfg->reorder_timeout; | 1786 | session->reorder_timeout = cfg->reorder_timeout; |
1787 | session->offset = cfg->offset; | 1787 | session->offset = cfg->offset; |
1788 | session->peer_offset = cfg->peer_offset; | ||
1788 | session->l2specific_type = cfg->l2specific_type; | 1789 | session->l2specific_type = cfg->l2specific_type; |
1789 | session->l2specific_len = cfg->l2specific_len; | 1790 | session->l2specific_len = cfg->l2specific_len; |
1790 | session->cookie_len = cfg->cookie_len; | 1791 | session->cookie_len = cfg->cookie_len; |
diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h index 9534e16965cc..c6fe7cc42a05 100644 --- a/net/l2tp/l2tp_core.h +++ b/net/l2tp/l2tp_core.h | |||
@@ -59,7 +59,8 @@ struct l2tp_session_cfg { | |||
59 | int debug; /* bitmask of debug message | 59 | int debug; /* bitmask of debug message |
60 | * categories */ | 60 | * categories */ |
61 | u16 vlan_id; /* VLAN pseudowire only */ | 61 | 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 */ | ||
63 | u16 l2specific_len; /* Layer 2 specific length */ | 64 | u16 l2specific_len; /* Layer 2 specific length */ |
64 | u16 l2specific_type; /* Layer 2 specific type */ | 65 | u16 l2specific_type; /* Layer 2 specific type */ |
65 | u8 cookie[8]; /* optional cookie */ | 66 | u8 cookie[8]; /* optional cookie */ |
@@ -86,8 +87,14 @@ struct l2tp_session { | |||
86 | int cookie_len; | 87 | int cookie_len; |
87 | u8 peer_cookie[8]; | 88 | u8 peer_cookie[8]; |
88 | int peer_cookie_len; | 89 | int peer_cookie_len; |
89 | u16 offset; /* offset from end of L2TP header | 90 | u16 offset; /* offset from end of L2TP |
90 | to beginning of data */ | 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 | */ | ||
91 | u16 l2specific_len; | 98 | u16 l2specific_len; |
92 | u16 l2specific_type; | 99 | u16 l2specific_type; |
93 | u16 hdr_len; | 100 | u16 hdr_len; |
diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c index eb69411bcb47..4cc30b38aba4 100644 --- a/net/l2tp/l2tp_debugfs.c +++ b/net/l2tp/l2tp_debugfs.c | |||
@@ -180,8 +180,9 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v) | |||
180 | session->lns_mode ? "LNS" : "LAC", | 180 | session->lns_mode ? "LNS" : "LAC", |
181 | session->debug, | 181 | session->debug, |
182 | jiffies_to_msecs(session->reorder_timeout)); | 182 | jiffies_to_msecs(session->reorder_timeout)); |
183 | seq_printf(m, " offset %hu l2specific %hu/%hu\n", | 183 | seq_printf(m, " offset %hu peer_offset %hu l2specific %hu/%hu\n", |
184 | session->offset, session->l2specific_type, session->l2specific_len); | 184 | session->offset, session->peer_offset, |
185 | session->l2specific_type, session->l2specific_len); | ||
185 | if (session->cookie_len) { | 186 | if (session->cookie_len) { |
186 | seq_printf(m, " cookie %02x%02x%02x%02x", | 187 | seq_printf(m, " cookie %02x%02x%02x%02x", |
187 | session->cookie[0], session->cookie[1], | 188 | session->cookie[0], session->cookie[1], |
@@ -228,7 +229,8 @@ static int l2tp_dfs_seq_show(struct seq_file *m, void *v) | |||
228 | seq_puts(m, " debug tx-pkts/bytes/errs rx-pkts/bytes/errs\n"); | 229 | seq_puts(m, " debug tx-pkts/bytes/errs rx-pkts/bytes/errs\n"); |
229 | seq_puts(m, " SESSION ID, peer ID, PWTYPE\n"); | 230 | seq_puts(m, " SESSION ID, peer ID, PWTYPE\n"); |
230 | seq_puts(m, " refcnt cnt\n"); | 231 | 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"); | ||
232 | seq_puts(m, " [ cookie ]\n"); | 234 | seq_puts(m, " [ cookie ]\n"); |
233 | seq_puts(m, " [ peer cookie ]\n"); | 235 | seq_puts(m, " [ peer cookie ]\n"); |
234 | seq_puts(m, " config mtu/mru/rcvseq/sendseq/dataseq/lns debug reorderto\n"); | 236 | seq_puts(m, " config mtu/mru/rcvseq/sendseq/dataseq/lns debug reorderto\n"); |
diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c index 7e9c50125556..d7d4d7a7a54d 100644 --- a/net/l2tp/l2tp_netlink.c +++ b/net/l2tp/l2tp_netlink.c | |||
@@ -547,9 +547,25 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf | |||
547 | } | 547 | } |
548 | 548 | ||
549 | if (tunnel->version > 2) { | 549 | 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]) { | ||
551 | cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]); | 558 | cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]); |
552 | 559 | ||
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 | |||
553 | if (info->attrs[L2TP_ATTR_DATA_SEQ]) | 569 | if (info->attrs[L2TP_ATTR_DATA_SEQ]) |
554 | cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]); | 570 | cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]); |
555 | 571 | ||
@@ -763,6 +779,8 @@ static int l2tp_nl_session_send(struct sk_buff *skb, u32 portid, u32 seq, int fl | |||
763 | nla_put_string(skb, L2TP_ATTR_IFNAME, session->ifname)) || | 779 | nla_put_string(skb, L2TP_ATTR_IFNAME, session->ifname)) || |
764 | (session->offset && | 780 | (session->offset && |
765 | nla_put_u16(skb, L2TP_ATTR_OFFSET, 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)) || | ||
766 | (session->cookie_len && | 784 | (session->cookie_len && |
767 | nla_put(skb, L2TP_ATTR_COOKIE, session->cookie_len, | 785 | nla_put(skb, L2TP_ATTR_COOKIE, session->cookie_len, |
768 | &session->cookie[0])) || | 786 | &session->cookie[0])) || |
@@ -903,6 +921,7 @@ static const struct nla_policy l2tp_nl_policy[L2TP_ATTR_MAX + 1] = { | |||
903 | [L2TP_ATTR_PW_TYPE] = { .type = NLA_U16, }, | 921 | [L2TP_ATTR_PW_TYPE] = { .type = NLA_U16, }, |
904 | [L2TP_ATTR_ENCAP_TYPE] = { .type = NLA_U16, }, | 922 | [L2TP_ATTR_ENCAP_TYPE] = { .type = NLA_U16, }, |
905 | [L2TP_ATTR_OFFSET] = { .type = NLA_U16, }, | 923 | [L2TP_ATTR_OFFSET] = { .type = NLA_U16, }, |
924 | [L2TP_ATTR_PEER_OFFSET] = { .type = NLA_U16, }, | ||
906 | [L2TP_ATTR_DATA_SEQ] = { .type = NLA_U8, }, | 925 | [L2TP_ATTR_DATA_SEQ] = { .type = NLA_U8, }, |
907 | [L2TP_ATTR_L2SPEC_TYPE] = { .type = NLA_U8, }, | 926 | [L2TP_ATTR_L2SPEC_TYPE] = { .type = NLA_U8, }, |
908 | [L2TP_ATTR_L2SPEC_LEN] = { .type = NLA_U8, }, | 927 | [L2TP_ATTR_L2SPEC_LEN] = { .type = NLA_U8, }, |