public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andreas Schultz <aschultz@tpip•net>
To: pablo <pablo@netfilter•org>
Cc: netdev <netdev@vger•kernel.org>, laforge <laforge@gnumonks•org>,
	Lionel Gauthier <Lionel.Gauthier@eurecom•fr>,
	openbsc <openbsc@lists•osmocom.org>
Subject: Re: [PATCH net-next v2 5/6] gtp: add socket to pdp context
Date: Thu, 2 Feb 2017 16:07:23 +0100 (CET)	[thread overview]
Message-ID: <2083605423.731432.1486048043458.JavaMail.zimbra@tpip.net> (raw)
In-Reply-To: <20170202144606.GA19992@salvia>



----- On Feb 2, 2017, at 3:46 PM, pablo pablo@netfilter•org wrote:

> On Thu, Feb 02, 2017 at 03:38:07PM +0100, Andreas Schultz wrote:
>> 
>> 
>> ----- On Feb 2, 2017, at 3:28 PM, pablo pablo@netfilter•org wrote:
>> 
>> > On Thu, Feb 02, 2017 at 03:12:55PM +0100, Andreas Schultz wrote:
>> >> Hi,
>> >> 
>> >> ----- On Feb 2, 2017, at 2:56 PM, pablo pablo@netfilter•org wrote:
>> >> 
>> >> > On Mon, Jan 30, 2017 at 05:37:12PM +0100, Andreas Schultz wrote:
>> >> >> Having the socket present in context simplifies the sending logic.
>> >> >> It also fixes the invalid assumption that we have to use the same
>> >> >> sending socket for all client IP's on a specific gtp interface.
>> >> >> 
>> >> >> Signed-off-by: Andreas Schultz <aschultz@tpip•net>
>> >> >> ---
>> >> >>  drivers/net/gtp.c | 72 ++++++++++++++++++++++++++++++-------------------------
>> >> >>  1 file changed, 39 insertions(+), 33 deletions(-)
>> >> >> 
>> >> >> diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
>> >> >> index 68c6c9b..ff00597 100644
>> >> >> --- a/drivers/net/gtp.c
>> >> >> +++ b/drivers/net/gtp.c
>> >> > [...]
>> >> >> @@ -984,16 +966,26 @@ static int ipv4_pdp_add(struct gtp_dev *gtp, struct
>> >> >> genl_info *info)
>> >> >>  	return 0;
>> >> >>  }
>> >> >>  
>> >> >> +static void pdp_context_free(struct rcu_head *head)
>> >> >> +{
>> >> >> +	struct pdp_ctx *pctx = container_of(head, struct pdp_ctx, rcu_head);
>> >> >> +
>> >> >> +	sock_put(pctx->sk);
>> >> >> +	kfree(pctx);
>> >> >> +}
>> >> >> +
>> >> >>  static void pdp_context_delete(struct pdp_ctx *pctx)
>> >> >>  {
>> >> >>  	hlist_del_rcu(&pctx->hlist_tid);
>> >> >>  	hlist_del_rcu(&pctx->hlist_addr);
>> >> >> -	kfree(pctx);
>> >> >> +	call_rcu(&pctx->rcu_head, pdp_context_free);
>> >> > 
>> >> > This is fixing incorrect rcu conversion in 4/6. Please, fix this there.
>> >> 
>> >> Ehm, right, but the kfree in 4/6 could have been a kfree_rcu instead without
>> >> the call_rcu.
>> >> 
>> >> Do you prefer to introduce the call_rcu in 4/6 and then just add the sock_put
>> >> in this patch or should I change 4/6 to kfree_rcu and do the call_rcu
>> >> conversion here?
>> > 
>> > I suggest you just call kfree_rcu() from 4/6.
>> > 
>> > Regarding holding socket reference, see my comment for patch 1/6.
>> 
>> This is going to be a problem at this stage of the changes.
>> 
>> The final goal is to have a reference from the socket to the pdp context.
> 
> Is this just a cleanup? Or you need this sk caching for some follow up
> work?

It's not caching, the plan is to completely remove the socket from the
GTP netdevice (as far as that is possible without breaking the existing API).

A GGSN or PGW can serve multiple APN's on the same GTP-U socket. Those APN's
can have overlapping IP address ranges. The only sensible way to handle
this, is to have a netdevice per APN. This breaks the current 1:1 relation
between sockets and netdevices.

Andreas

> 
>> Then, when the socket is closed, the pdp context can be destroyed.
>>
>> However, at this point, only the netdevice knows about the contexts. So
>> when the socket is closed, the pdp context would have a dangling reference
>> to the socket.
>>
>> I can integrate this change into the later one. But it will make that
>> change larger and more difficult to review.
>> 
>> I guess, I'm going to drop this change from this series and see if can
>> reorder the next part so that it still makes and I easy to review....
> 
> Agreed. Thanks.

  reply	other threads:[~2017-02-02 15:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-30 16:37 [PATCH net-next v2 0/6] gtp: misc improvements Andreas Schultz
2017-01-30 16:37 ` [PATCH net-next v2 1/6] gtp: make GTP sockets in gtp_newlink optional Andreas Schultz
2017-02-02 14:10   ` Pablo Neira Ayuso
2017-02-02 14:30     ` Andreas Schultz
2017-02-02 14:32       ` Pablo Neira Ayuso
2017-02-06 13:51   ` Harald Welte
2017-01-30 16:37 ` [PATCH net-next v2 2/6] gtp: merge gtp_get_net and gtp_genl_find_dev Andreas Schultz
2017-02-06 13:55   ` Harald Welte
2017-02-13 14:13     ` Andreas Schultz
2017-02-13 14:51       ` Pablo Neira Ayuso
2017-01-30 16:37 ` [PATCH net-next v2 3/6] gtp: unify genl_find_pdp and prepare for per socket lookup Andreas Schultz
2017-02-02 14:19   ` Pablo Neira Ayuso
2017-02-02 14:27     ` Andreas Schultz
2017-02-02 14:31       ` Pablo Neira Ayuso
2017-02-06 13:56   ` Harald Welte
2017-01-30 16:37 ` [PATCH net-next v2 4/6] gtp: consolidate pdp context destruction into helper Andreas Schultz
2017-02-06 13:58   ` Harald Welte
2017-02-13 14:14     ` Andreas Schultz
2017-01-30 16:37 ` [PATCH net-next v2 5/6] gtp: add socket to pdp context Andreas Schultz
2017-02-02 13:56   ` Pablo Neira Ayuso
2017-02-02 14:12     ` Andreas Schultz
2017-02-02 14:28       ` Pablo Neira Ayuso
2017-02-02 14:38         ` Andreas Schultz
2017-02-02 14:46           ` Pablo Neira Ayuso
2017-02-02 15:07             ` Andreas Schultz [this message]
2017-02-06 14:04               ` Harald Welte
2017-01-30 16:37 ` [PATCH net-next v2 6/6] gtp: consolidate gtp socket rx path Andreas Schultz
2017-01-31 18:05 ` [PATCH net-next v2 0/6] gtp: misc improvements David Miller
2017-02-06 13:46   ` Harald Welte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2083605423.731432.1486048043458.JavaMail.zimbra@tpip.net \
    --to=aschultz@tpip$(echo .)net \
    --cc=Lionel.Gauthier@eurecom$(echo .)fr \
    --cc=laforge@gnumonks$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=openbsc@lists$(echo .)osmocom.org \
    --cc=pablo@netfilter$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox