From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Barmann Subject: Re: [PATCH net-next] sock: Reset dst when changing sk_mark via setsockopt Date: Wed, 7 Nov 2018 17:07:32 -0600 Message-ID: <20181107230732.GA21388@konacove.com> References: <20181107223327.GA21018@konacove.com> <4a6b111a-c0d2-e12c-bc42-3c723a0297bc@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Eric Dumazet To: netdev@vger.kernel.org Return-path: Received: from konacove.com ([69.16.156.219]:47562 "EHLO konacove.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbeKHIkH (ORCPT ); Thu, 8 Nov 2018 03:40:07 -0500 Content-Disposition: inline In-Reply-To: <4a6b111a-c0d2-e12c-bc42-3c723a0297bc@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: > On 11/07/2018 02:33 PM, David Barmann wrote: > > When setting the SO_MARK socket option, the dst needs to be reset so > > that a new route lookup is performed. > > > > This fixes the case where an application wants to change routing by > > setting a new sk_mark. If this is done after some packets have already > > been sent, the dst is cached and has no effect. > > > > + } else { > > + struct dst_entry *dst = sk_dst_get(sk); > > sk->sk_mark = val; > > + sk_dst_reset(sk); > > > sk_dst_get() and dst_release() seems extra overhead ? > > net/ipv4/ip_sockglue.c do_ip_setsockopt() has a similar handling for IP_TOS, > and it only calls sk_dst_reset() (If the new TOS is different than the current one) > > > > So I would suggest : > > if (!ns_capable(...)) { > ret = -EPERM; > } else if (val != sk->sk_mark) { > sk->sk_mark = val; > sk_dst_reset(sk); > } Thanks Eric, I'll redo that and resubmit. -David