Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp487imu; Fri, 14 Dec 2018 13:13:58 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vu6AW+4eQVlGzZmjNhE992hu9p9IEg8p4PJvpV+Udzzv9w/qU/i4ftRoY3T+eM8Fy3N51C X-Received: by 2002:a63:9a09:: with SMTP id o9mr3942048pge.94.1544822038333; Fri, 14 Dec 2018 13:13:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544822038; cv=none; d=google.com; s=arc-20160816; b=FA2AVy+iLGa5iyCBhTGDnJk9FLFYAb9gvSVKKARTUr121hJcyePpCrZiIQL3xXMu1C AU5wUiYRmzFOLF592qc7qX0+TxlQQL93JSuKr4z1yAJgY8yQrNtwzh3vH6HE5qamPwo6 QaqVxg5tAJlpNx72h1H1cwJwDDr4tSHfz9uLkeZiVvdgl3PUJryygJ1g0fUixOSkKC68 ixOz1zy9DbtaPZSjrhZXhB+E9feuDvPcPKqgVsDVSpNFJLh6NASMaEj2pG9GG02LzlL2 7A+RVwZWNAa1+Hqb3cHA5SdgSwSjO3K2xuHatVpTlJGFXCgLdAQ69t0DjfR3Xwdf/+hZ UXdg== 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 g20si4987260pgh.241.2018.12.14.13.13.41; Fri, 14 Dec 2018 13:13:58 -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 S1731199AbeLNVMs (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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(+) 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; -- 2.19.1