From owner-freebsd-current@freebsd.org Sat Nov 21 22:48:21 2020 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8DBE2472BB4 for ; Sat, 21 Nov 2020 22:48:21 +0000 (UTC) (envelope-from guyyur@gmail.com) Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CdpVD1bhNz3l7B; Sat, 21 Nov 2020 22:48:19 +0000 (UTC) (envelope-from guyyur@gmail.com) Received: by mail-wm1-x32e.google.com with SMTP id s13so13800513wmh.4; Sat, 21 Nov 2020 14:48:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=SXGXGOy42+2p6fqBTYGCDtabLxqJYRH/rerdFFpJxUs=; b=YbMdMKTeznUKQ4XwgZ9+w3+yO8PisuRSWmnbWgteGVlR5ku6y8qaQAbEnnBBrD28nq lUzpp4hLcrGoi2UGtHRHDoyeJm40WG4JJolgrBl8F8cLkSAQX4ziaeCDJTDOqQlzYcGD a3NAJ3sP1LXXCrNKBGO6eWQRCO9o+EOcYhM0wIIh6WCTBD305veisXyUcmKvkWMEWnBh K5tnTz3hhk119ZDg468pKzzX0NAlqb2Q8VPDREcUQRYws48zNdMjX71c4II8hlFHGPSa 1o6YJuLAg1/1pFWIuYhRf0csRZz/7X4TXKgSQnkDb/rNl2+ZMwhC4ZovfPhD6tTAc92P BhpQ== X-Gm-Message-State: AOAM5331rk6aUYfBWnwY/WZDpUEK4XQZy7upQybTYtqG0VLv+UiM7S/3 2wQ1P/DU9XRMsqEevT0CMi+WKnyHQ13TKw== X-Google-Smtp-Source: ABdhPJwdcu8cjX9sdpa6hFQ2IRzO7htpkatfSrYewcE1hBoe717iVqx8jqpB5ZMjxF7/YgJpMlCkUw== X-Received: by 2002:a1c:a344:: with SMTP id m65mr16969128wme.77.1605998898254; Sat, 21 Nov 2020 14:48:18 -0800 (PST) Received: from ?IPv6:2a02:ed0:33ff:5501:33e8:8c9b:8d89:594d? ([2a02:ed0:33ff:5501:33e8:8c9b:8d89:594d]) by smtp.gmail.com with ESMTPSA id 31sm10987658wre.43.2020.11.21.14.48.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 Nov 2020 14:48:17 -0800 (PST) From: Guy Yur Subject: adding existing ipv6 network route returns ENOMEM instead of EEXIST if loopback route also exists To: melifaro@FreeBSD.org, freebsd-current@freebsd.org Message-ID: <9b1bb259-1307-7776-cc0b-e7a8eced6ac3@gmail.com> Date: Sun, 22 Nov 2020 00:48:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Rspamd-Queue-Id: 4CdpVD1bhNz3l7B X-Spamd-Bar: --- X-Spamd-Result: default: False [-4.00 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a00:1450:4864:20::32e:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; SPAMHAUS_ZRD(0.00)[2a00:1450:4864:20::32e:from:127.0.2.255]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::32e:from]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-current] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 22:48:21 -0000 Hi, When adding a route with a netmask, add_route() in route_ctl.c adds the route with destination address masked. If the add failed (for example, the route exists) it calls lookup_prefix() with the original unmasked destination. In a scenario where a loopback route was added followed by the network route being added, if the network route is added again and the network route destination is the same as the loopback route, lookup_prefix() will match on the loopback route, not finding the network route and add_route() will return ENOMEM instead of EEXIST. Adding the route with just the network part returns EEXIST as expected. Example: # route -6 add -host fd53::1111 -prefixlen 128 ::1 # route -6 add -net fd53::1111 -prefixlen 64 ::1 # route -6 add -net fd53::1111 -prefixlen 64 ::1 route: writing to routing socket: Cannot allocate memory add net fd53::1111: gateway ::1 fib 0: Cannot allocate memory # route -6 add -net fd53:: -prefixlen 64 ::1 add net fd53::: gateway ::1 fib 0: route already in table I was testing https://reviews.freebsd.org/D15406 changes applied to r367863. The changes call rtinit to add prefix route when interface address is added/updated and uses the interface address as the destination. rtinit returned ENOMEM instead of EEXIST causing dhcpcd to printCannot allocate memory. route commands above showing the problem were run in r367863 without D15406 changesas well. Thanks, Guy Yur