diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2017-12-22 15:10:18 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-12-27 12:11:51 -0500 |
commit | f15bc54eeecd86dfba3885aab839cd1f45172a38 (patch) | |
tree | b0ce5e53ca229d324ba653f64b9cc4ac34dd8e4b /net/l2tp/l2tp_netlink.c | |
parent | 820da5357572715c6235ba3b3daa2d5b43a1198f (diff) | |
download | linux-f15bc54eeecd86dfba3885aab839cd1f45172a38.tar.bz2 |
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/l2tp_netlink.c')
-rw-r--r-- | net/l2tp/l2tp_netlink.c | 21 |
1 files changed, 20 insertions, 1 deletions
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 } 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]); + /* 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]) 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)) || (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 && nla_put(skb, L2TP_ATTR_COOKIE, session->cookie_len, &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_ENCAP_TYPE] = { .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_L2SPEC_TYPE] = { .type = NLA_U8, }, [L2TP_ATTR_L2SPEC_LEN] = { .type = NLA_U8, }, |