From patchwork Wed May 5 23:28:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth David Schoen X-Patchwork-Id: 12241315 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBD03C433B4 for ; Wed, 5 May 2021 23:28:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7916613B3 for ; Wed, 5 May 2021 23:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbhEEX3O (ORCPT ); Wed, 5 May 2021 19:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231220AbhEEX3L (ORCPT ); Wed, 5 May 2021 19:29:11 -0400 Received: from frotz.zork.net (frotz.zork.net [IPv6:2600:3c00:e000:35f::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A523FC061574 for ; Wed, 5 May 2021 16:28:14 -0700 (PDT) Received: by frotz.zork.net (Postfix, from userid 1008) id 2B1D11199F; Wed, 5 May 2021 23:28:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 frotz.zork.net 2B1D11199F Date: Wed, 5 May 2021 16:28:12 -0700 From: Seth David Schoen To: netdev@vger.kernel.org Cc: gnu@toad.com, dave.taht@gmail.com Subject: [RESEND PATCH net-next 1/2] ip: Treat IPv4 segment's lowest address as unicast Message-ID: <20210505232812.GQ2734@frotz.zork.net> Mail-Followup-To: Seth David Schoen , netdev@vger.kernel.org, gnu@toad.com, dave.taht@gmail.com References: <20210505232508.GA1040923@frotz.zork.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210505232508.GA1040923@frotz.zork.net> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Treat only the highest, not the lowest, IPv4 address within a local subnet as a broadcast address. Signed-off-by: Seth David Schoen Suggested-by: John Gilmore Acked-by: Dave Taht --- net/ipv4/fib_frontend.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 84bb707bd88d..bfb345c88271 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -1122,10 +1122,8 @@ void fib_add_ifaddr(struct in_ifaddr *ifa) prefix, ifa->ifa_prefixlen, prim, ifa->ifa_rt_priority); - /* Add network specific broadcasts, when it takes a sense */ + /* Add the network broadcast address, when it makes sense */ if (ifa->ifa_prefixlen < 31) { - fib_magic(RTM_NEWROUTE, RTN_BROADCAST, prefix, 32, - prim, 0); fib_magic(RTM_NEWROUTE, RTN_BROADCAST, prefix | ~mask, 32, prim, 0); } From patchwork Wed May 5 23:29:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth David Schoen X-Patchwork-Id: 12241317 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E24EFC433B4 for ; Wed, 5 May 2021 23:29:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9365613B3 for ; Wed, 5 May 2021 23:29:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231127AbhEEXaJ (ORCPT ); Wed, 5 May 2021 19:30:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229881AbhEEXaI (ORCPT ); Wed, 5 May 2021 19:30:08 -0400 Received: from frotz.zork.net (frotz.zork.net [IPv6:2600:3c00:e000:35f::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68321C061574 for ; Wed, 5 May 2021 16:29:11 -0700 (PDT) Received: by frotz.zork.net (Postfix, from userid 1008) id D5C851199F; Wed, 5 May 2021 23:29:09 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 frotz.zork.net D5C851199F Date: Wed, 5 May 2021 16:29:09 -0700 From: Seth David Schoen To: netdev@vger.kernel.org Cc: gnu@toad.com, dave.taht@gmail.com Subject: [RESEND PATCH net-next 2/2] selftests: Lowest IPv4 address in a subnet is valid Message-ID: <20210505232909.GR2734@frotz.zork.net> Mail-Followup-To: Seth David Schoen , netdev@vger.kernel.org, gnu@toad.com, dave.taht@gmail.com References: <20210505232508.GA1040923@frotz.zork.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210505232508.GA1040923@frotz.zork.net> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Expect the lowest IPv4 address in a subnet to be assignable and addressable as a unicast (non-broadcast) address on a local network segment. Signed-off-by: Seth David Schoen Suggested-by: John Gilmore Acked-by: Dave Taht --- .../testing/selftests/net/unicast_extensions.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/net/unicast_extensions.sh b/tools/testing/selftests/net/unicast_extensions.sh index dbf0421986df..66354cdd5ce4 100755 --- a/tools/testing/selftests/net/unicast_extensions.sh +++ b/tools/testing/selftests/net/unicast_extensions.sh @@ -189,6 +189,15 @@ segmenttest 255.255.255.1 255.255.255.254 24 "assign and ping inside 255.255.255 route_test 240.5.6.7 240.5.6.1 255.1.2.1 255.1.2.3 24 "route between 240.5.6/24 and 255.1.2/24 (is allowed)" route_test 0.200.6.7 0.200.38.1 245.99.101.1 245.99.200.111 16 "route between 0.200/16 and 245.99/16 (is allowed)" # +# Test support for lowest address ending in .0 +segmenttest 5.10.15.20 5.10.15.0 24 "assign and ping lowest address (/24)" +# +# Test support for lowest address not ending in .0 +segmenttest 192.168.101.192 192.168.101.193 26 "assign and ping lowest address (/26)" +# +# Routing using lowest address as a gateway/endpoint +route_test 192.168.42.1 192.168.42.0 9.8.7.6 9.8.7.0 24 "routing using lowest address" +# # ============================================== # ==== TESTS THAT CURRENTLY EXPECT FAILURE ===== # ============================================== @@ -202,14 +211,6 @@ segmenttest 255.255.255.1 255.255.255.255 16 "assigning 255.255.255.255 (is forb # Currently Linux does not allow this, so this should fail too segmenttest 127.99.4.5 127.99.4.6 16 "assign and ping inside 127/8 (is forbidden)" # -# Test support for lowest address -# Currently Linux does not allow this, so this should fail too -segmenttest 5.10.15.20 5.10.15.0 24 "assign and ping lowest address (is forbidden)" -# -# Routing using lowest address as a gateway/endpoint -# Currently Linux does not allow this, so this should fail too -route_test 192.168.42.1 192.168.42.0 9.8.7.6 9.8.7.0 24 "routing using lowest address (is forbidden)" -# # Test support for unicast use of class D # Currently Linux does not allow this, so this should fail too segmenttest 225.1.2.3 225.1.2.200 24 "assign and ping class D address (is forbidden)"