From patchwork Mon Jan 28 18:22:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 1032141 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=herbertland.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=herbertland-com.20150623.gappssmtp.com header.i=@herbertland-com.20150623.gappssmtp.com header.b="F9r3ZXgO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43pJ0N3lflz9s3q for ; Tue, 29 Jan 2019 05:23:16 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727410AbfA1SXP (ORCPT ); Mon, 28 Jan 2019 13:23:15 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36052 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727403AbfA1SXP (ORCPT ); Mon, 28 Jan 2019 13:23:15 -0500 Received: by mail-pf1-f194.google.com with SMTP id b85so8382669pfc.3 for ; Mon, 28 Jan 2019 10:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=herbertland-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=daUmnxiiFihbKWCFNzv7+rxuGU5a2GnX+mQdKnzzkN0=; b=F9r3ZXgOfc+dhMQdsY4pM8Xm/eTvrVlNo6jaNJn0giupj1pmuOlecV3USpeTHa/ICO V7bnfyMEL1boi/yhELzhoGyRi8VgfKKIDZM3rxd6jSS7F5VUX79efqZLe2FOyUPpDHUt IwkHcXKFOz+sQdJjpIucldzNdXzXXLkKCgBkuqKRe2hDpYDfhf6igZWkACqI2wcTCf02 M/xU6JH6wim0/pFEcMNhe9bhXWZkcFPy0lZ/yrmeFEQSRvfjof+55Rcz0NUH57/dZkzH Wo/HE9oIC8A3OBdT9oQ8OHBkHfthp9OJdzfWQSmn6GNbp9hDc9NFI+BrWrl/Rl+rw0qp I8FQ== 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; bh=daUmnxiiFihbKWCFNzv7+rxuGU5a2GnX+mQdKnzzkN0=; b=G60cU9Fo1hVzh1zF13gIp4r+8PnROsRU0dmhZwmw9khKEOGdPZ/Yk1EOKVi8Ywro0q EOBmjKSTgTYy3FiGDtjJmOUUlWmps7nHYYCziF1NVyQQNmN8lAFycK/Z0iHmrqvofA5Y VB+Xhk9W6/Mv+mIP5Khzl6tvAcJlFlSZeBHy40m5G97JkL59gHBn9oVOE/bMSYSZnXzk 0hd+sqJMWA4OatlndxwfTFDztOKHY+qPA+QPn2PgEcMQL9nB94YSKGQtEL/3yiZ3Q+z+ d7oVj7pY87RjChCeSNHFp1hJgJH5ZOHLogQqJUnVpO5iAaKWuqr483Vv0kASxf3gMYOO syww== X-Gm-Message-State: AJcUukc3aOUgBNuCp+GASxkK1K4Kya60piCdY2I9YVB6MI/fUsROH/s3 bCLY9n3Qy3dI1wR0U7yRuUT0MfBP/Xk= X-Google-Smtp-Source: ALg8bN4TOrJ7N0tNKjrW3qc8yeiloxFZI3UpTLBTWWXbGDSmWJJ1LGwsCNijFIFGf4M6qggt0SbLkQ== X-Received: by 2002:a62:28c9:: with SMTP id o192mr23349654pfo.57.1548699794394; Mon, 28 Jan 2019 10:23:14 -0800 (PST) Received: from localhost.localdomain (c-73-223-249-119.hsd1.ca.comcast.net. [73.223.249.119]) by smtp.gmail.com with ESMTPSA id n78sm61777238pfk.19.2019.01.28.10.23.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 10:23:13 -0800 (PST) From: Tom Herbert X-Google-Original-From: Tom Herbert To: davem@davemloft.net, netdev@vger.kernel.org Cc: Tom Herbert Subject: [PATCH v2 net-next 0/5] ipv6: Rework infrastructure for TLV options in extension headers Date: Mon, 28 Jan 2019 10:22:50 -0800 Message-Id: <1548699775-3015-1-git-send-email-tom@quantonium.net> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch set implements an infrastructure to allow fine grained control over IPv6 Destination and Hop-by-Hop TLV options. This includes being able to registers handlers for receiving options as well as a set of parameters that sets permissions for who may send a TLV option and the preferred format of a list of options. The goal of the patch is to enable broader use cases of IPv6 options, including those for which non-privileged users can send options. In order to curtail misuse of options in such cases, a number of requirements on how the option may be sent and formatted is enforced. Particular features are: - A single TLV paramters table containing the information about each TLV is defined. Lookups are simple offset accesses to the table based on TLV type. Both receiving and sending properties of TLVs are maintained in the table. - Allow registration/deregistration of receive handlers for specific TLVs. - Describe the properties of sending different TLVs in a TLV parameter table. The parameter table can be managed via netlink. - Allow non-privileged users to send TLVs for which they have been granted permission. - Provide a deep validation of TLVs and TLV lists to enforce specific limits and permission in order to thwart misuse of TLVs. - Define a canonical format for sending TLVs that includes a preferred order, option alignment, minimal padding between TLVs. - Allow individual TLVs to be added or set in txoptions list on a socket. Tested: Write and read different TLVs on a socket via setsockopt and getsockopt. Flow is add individual TLV, read back options, set read option on new socket as a list. Verify options are properly sent and received. Used a modified ip command in iproute2 to test managing the TLV parameter via netlink. v2: - Change the TLV parameters table to be an array of u8s as opposed to pointers. Each entry gives the offset into a second array of TLV parameters structures. This reduces the memory footprint needed for the table but still allows O(1) lookups on TLV type. Tom Herbert (5): exthdrs: Create exthdrs_options.c exthdrs: Registration of TLV handlers and parameters ip6tlvs: Add netlink interface ip6tlvs: Validation of TX Destination and Hop-by-Hop options ip6tlvs: API to set and remove individual TLVs from DO or HBH EH include/net/ipv6.h | 82 ++ include/uapi/linux/in6.h | 58 ++ net/ipv6/Makefile | 2 +- net/ipv6/datagram.c | 27 +- net/ipv6/exthdrs.c | 389 +--------- net/ipv6/exthdrs_options.c | 1798 ++++++++++++++++++++++++++++++++++++++++++++ net/ipv6/ipv6_sockglue.c | 110 ++- 7 files changed, 2089 insertions(+), 377 deletions(-) create mode 100644 net/ipv6/exthdrs_options.c