From patchwork Fri Dec 14 21:12:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 153905 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2548223ljp; Fri, 14 Dec 2018 13:12:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/U48dvH/cje+iKD986erVJhRAjsxMC195rMYEbz5SrdJ5V0+xxCAAjApPJ1W+0ntJfuimi7 X-Received: by 2002:a62:cdd:: with SMTP id 90mr4282850pfm.219.1544821969582; Fri, 14 Dec 2018 13:12:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544821969; cv=none; d=google.com; s=arc-20160816; b=chmnsS7s3rtzeA6qbnbld7sNLQsLqPD1NQFy2JUfXpRC0nb8zT4rW/sV+AziG+dblW MMBFiAJGeaSJjQJ3T54aS2HN4XSQ+CXZKMdLOEuPFo3/t1lJReOtD4yeM37o4AYMmjaI pCRKrXIMPFZrQyseoYHvjY52GT6udETNZwNLGDmuNYOmDh4zeTdpM4P7JhQPyTrpV73p 9bpxUrGsfwvvGmvAM5iyYtqPrDXhWxvNPTBJvh2N/e4oICeaCpwUK2Ps86WAo9Bd196B OOZ7l5kXoJVJUe3X5cBbvfNzEaor4fUXZEqYsrBahsudzdl3/veyX/ZHIXCJ3dcVPp2X N6GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tyNnUR4lfp/hoy1rKAT2aYL4FMj9E3HybgGC/oR7mho=; b=J8u5ofWIxWEfJVg3SoFVmJxHhf80YqTTCeToE1OmiRfOhqXxrmS09+pIISoa3dsBeg IZsmAWWgRFdb0wJUpeAGdSS7jyvuyTMrgZ0DbvVePf3RHqazGdCCda4GT2Eg2ij+Hr8f gKJ6Q/BrGi7pgI7UO4dT82QNepfIB+83Jmd4dwTmyleqkRcPBUfopmdPk8kxle4NqWd6 ggC0TUmYeYsZA5FRzFDmNnQeowe6vVwMWxUWDxQBC4/F39g1eZuSbFPjytDPhzAmCIGx POOnXBUQZUmN5u3vUuhfIPOEq1+6flZ1XHcUDgXnqZz5fqRAsJaF43o1MUL+ATcQF9ko 84LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KTTC98pi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y20si4655843plr.106.2018.12.14.13.12.49; Fri, 14 Dec 2018 13:12:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KTTC98pi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731212AbeLNVMs (ORCPT + 31 others); Fri, 14 Dec 2018 16:12:48 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45754 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730956AbeLNVMq (ORCPT ); Fri, 14 Dec 2018 16:12:46 -0500 Received: by mail-lf1-f66.google.com with SMTP id b20so5272590lfa.12 for ; Fri, 14 Dec 2018 13:12:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tyNnUR4lfp/hoy1rKAT2aYL4FMj9E3HybgGC/oR7mho=; b=KTTC98piaTj0WoYaI4cfpgCrMgv52G2aSZ5Cth1Hq8a38qUM7NQyNvnv95AO6a2XSc cAtgsvbmnHavFmJmCLtCJ0Q1Zfi9xQ4R6Nc7qbXDnK40nKiA0p6Qo8k60+peRor/YxXm hwfsX/TO/4ohhNm/F0C7AdcOfaTzsonNjooz8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tyNnUR4lfp/hoy1rKAT2aYL4FMj9E3HybgGC/oR7mho=; b=iem0Lwn0WZbXZdnBJ1W5dFS08cu7k5hFAL58RTpymyPth1tCZbHcj7s0RixcDfnarZ lmA9FwTWozu13XhqgMfKt6CTmxikYzY1CyULL9lDftguG1MO5AFAK65ketmttME9fZI1 8pmW0tZpDD+r+gXANx+Hi1TswyJ5oXp6u2pVP4e6XmVyakY/JNr8XfRqVMJh5LUfsrO7 UNVutILtXc+7TVJRYVzahoJo2z/vXsVkFOkBBfpD7aaq4eR8girlfy7fz0skYcBRuohC f2vRqifvWODeRKsUQK7S7cBtz+d+m6x1gKJOzQjANIaCM+oqq+H5fNXm4yfjtYHoRC6U cj7w== X-Gm-Message-State: AA+aEWYuV3y+PaztzdT+orqNuDmVhhCou9W/Omo7w+pO/uKljQXQeNmS 6pLHdWIFAuQ0kzsZ3mAnuAAJRA== X-Received: by 2002:a19:5782:: with SMTP id l124mr2569905lfb.91.1544821964480; Fri, 14 Dec 2018 13:12:44 -0800 (PST) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id u15-v6sm1190636lja.63.2018.12.14.13.12.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Dec 2018 13:12:44 -0800 (PST) From: Sam Protsenko To: James Chapman , "David S. Miller" Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Guillaume Nault Subject: [PATCH 2/2] l2tp: Add Protocol field compression Date: Fri, 14 Dec 2018 23:12:42 +0200 Message-Id: <20181214211242.9721-2-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181214211242.9721-1-semen.protsenko@linaro.org> References: <20181214211242.9721-1-semen.protsenko@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When Protocol Field Compression (PFC) is enabled, the "Protocol" field in PPP packet should be transmitted without leading 0x00. See section 6.5 in RFC 1661 for details. Let's compress protocol field if needed, the same way it's done in drivers/net/ppp/pptp.c. To actually enable PFC, one should issue corresponding ioctl to L2TP driver from user-space, like this: ioctl(fd, PPPIOCGFLAGS, &flags); flags |= SC_COMP_PROT; ioctl(fd, PPPIOCSFLAGS, &flags); It can be done e.g. from pppol2tp plugin (pppd), when pcomp option was negotiated with peer. Of course, we don't compress Protocol field when sending LCP packets. As stated in RFC 1661, section 6.5: The Protocol field is never compressed when sending any LCP packet. This rule guarantees unambiguous recognition of LCP packets. Signed-off-by: Sam Protsenko --- net/l2tp/l2tp_ppp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.19.1 diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 145435977b21..7860b219af07 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c @@ -363,7 +363,10 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb) struct sock *sk = (struct sock *) chan->private; struct l2tp_session *session; struct l2tp_tunnel *tunnel; + struct pppol2tp_session *ps; int uhlen, headroom; + unsigned char *data; + bool is_lcp; if (sock_flag(sk, SOCK_DEAD) || !(sk->sk_state & PPPOX_CONNECTED)) goto abort; @@ -384,6 +387,15 @@ static int pppol2tp_xmit(struct ppp_channel *chan, struct sk_buff *skb) if (skb_cow_head(skb, headroom)) goto abort_put_sess; + ps = l2tp_session_priv(session); + data = skb->data; + is_lcp = ((data[0] << 8) + data[1]) == PPP_LCP && + data[2] >= 1 && data[2] <= 7; + + /* Compress protocol field if PFC is enabled */ + if ((ps->flags & SC_COMP_PROT) && data[0] == 0x00 && !is_lcp) + __skb_pull(skb, 1); + /* Setup PPP header */ __skb_push(skb, 2); skb->data[0] = PPP_ALLSTATIONS;