From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH net-next v1 1/5] net: allow binding socket in a VRF when there's an unbound socket Date: Mon, 24 Sep 2018 16:44:05 -0600 Message-ID: References: <20180924161326.17167-1-mmanning@vyatta.att-mail.com> <20180924161326.17167-2-mmanning@vyatta.att-mail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Robert Shearman To: Mike Manning , netdev@vger.kernel.org Return-path: Received: from mail-pg1-f196.google.com ([209.85.215.196]:39546 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725843AbeIYEsh (ORCPT ); Tue, 25 Sep 2018 00:48:37 -0400 Received: by mail-pg1-f196.google.com with SMTP id 85-v6so6904624pge.6 for ; Mon, 24 Sep 2018 15:44:08 -0700 (PDT) In-Reply-To: <20180924161326.17167-2-mmanning@vyatta.att-mail.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 9/24/18 10:13 AM, Mike Manning wrote: > From: Robert Shearman > > There is no easy way currently for applications that want to receive > packets in the default VRF to be isolated from packets arriving in > VRFs, which makes using VRF-unaware applications in a VRF-aware system > a potential security risk. That comment is not correct. The point of the l3mdev sysctl's is to prohibit this case. Setting net.ipv4.{tcp,udp}_l3mdev_accept=0 means that a packet arriving on an interface enslaved to a VRF can not be received by a global socket. Setting the l3mdev to 1 allows the default socket to work across VRFs. If that is not what you want for a given app or a given VRF, then one option is to add netfilter rules on the VRF device to prohibit it. I just verified this works for both tcp and udp. Further, overlapping binds are allowed using SO_REUSEPORT meaning I can have a server running in the default vrf bound to a port AND a server running bound to a specific vrf and the same port: udp UNCONN 0 0 *%red:12345 *:* users:(("vrf-test",pid=1376,fd=3)) udp UNCONN 0 0 *:12345 *:* users:(("vrf-test",pid=1375,fd=3)) tcp LISTEN 0 1 *%red:12345 *:* users:(("vrf-test",pid=1356,fd=3)) tcp LISTEN 0 1 *:12345 *:* users:(("vrf-test",pid=1352,fd=3)) For packets arriving on an interface enslaved to a VRF the socket lookup will pick the VRF server over the global one.