Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Dmitry Kozlov <xeb@mail.ru>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH v4] PPTP: PPP over IPv4 (Point-to-Point Tunneling Protocol)
Date: Wed, 18 Aug 2010 15:03:46 +0200	[thread overview]
Message-ID: <1282136626.2194.68.camel@edumazet-laptop> (raw)
In-Reply-To: <E1OlhmZ-0002l6-00.xeb-mail-ru@f45.mail.ru>

Le mercredi 18 août 2010 à 16:30 +0400, Dmitry Kozlov a écrit :
> This patch contains:
> 1. pptp driver
> 2. gre demultiplexer driver for demultiplexing gre packets with different gre version
>    so ip_gre and pptp may coexists
> 3. ip_gre modification
> 4. other stuff
> 
> Changes from patch v3:
> 1. using rcu instead of read-write lock in gre module
> 2. fixed coding style issues
> 

Hmm. You left a synchronize_rcu() call in add_chan() but this is not
necessary. Please remove it or explain why you think it is needed.

synchronize_rcu(); in del_chan() is now fine, thanks.


You use a mutex for gre_proto_lock, but you dont need a mutex, please
use a spinlock like I suggested. I would have said 'use a mutex' if if
was needed, you can trust me.

A mutex is needed if you can sleep while holding the lock, this is not
the case here. A spinlock is faster and reduces to no-op on !SMP

Also, please remove the synchronize_rcu() call from gre_add_protocol() :
It is not needed at all, like in add_chan().

(You dont have to wait for a RCU grace period when adding something,
only when removing from a data structure)

You sometime have too many tabulations, check :



> +	{
> +		struct flowi fl = { .oif = 0,
> +				    .nl_u = {

ip4_u has one excess level
> +							.ip4_u = {
> +								.daddr = opt->dst_addr.sin_addr.s_addr,
> +								.saddr = opt->src_addr.sin_addr.s_addr,
> +								.tos = RT_TOS(0) } },
> +				    .proto = IPPROTO_GRE };
> +		err = ip_route_output_key(&init_net, &rt, &fl);
> +		if (err)
> +			goto tx_error;
> +	}
> +	tdev = rt->u.dst.dev;
> +
> +	max_headroom = LL_RESERVED_SPACE(tdev) + sizeof(*iph) + sizeof(*hdr) + 2;
> +
> +	

same on this if clause. why so many leading spaces ?

> +	if (
> +					/* version should be 1 */
> +					((header->ver & 0x7F) != PPTP_GRE_VER) ||
> +					/* PPTP-GRE protocol for PPTP */
> +					(ntohs(header->protocol) != PPTP_GRE_PROTO) ||
> +					/* flag C should be clear   */
> +					PPTP_GRE_IS_C(header->flags) ||
> +					/* flag R should be clear   */
> +					PPTP_GRE_IS_R(header->flags) ||
> +					/* flag K should be set     */
> +					(!PPTP_GRE_IS_K(header->flags)) ||
> +					/* routing and recursion ctrl = 0  */
> +					((header->flags&0xF) != 0))
> +					/* if invalid, discard this packet */
> +		goto drop;
> +
> +
> +	po = lookup_chan(htons(header->call_id), iph->saddr);

...

> +
> +	{
> +		struct flowi fl = {
> +				    .nl_u = {

ditto

> +							.ip4_u = {
> +								.daddr = opt->dst_addr.sin_addr.s_addr,
> +								.saddr = opt->src_addr.sin_addr.s_addr,
> +								.tos = RT_CONN_FLAGS(sk) } },
> +				    .proto = IPPROTO_GRE };
> +		security_sk_classify_flow(sk, &fl);
> +		if (ip_route_output_key(&init_net, &rt, &fl)) {
> +			error = -EHOSTUNREACH;
> +			goto end;
> +		}
> +		sk_setup_caps(sk, &rt->u.dst);
> +	}

Thanks



  reply	other threads:[~2010-08-18 13:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-18 12:30 [PATCH v4] PPTP: PPP over IPv4 (Point-to-Point Tunneling Protocol) Dmitry Kozlov
2010-08-18 13:03 ` Eric Dumazet [this message]
2010-08-18 13:16   ` Dmitry Kozlov
2010-08-18 13:28     ` Eric Dumazet

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=1282136626.2194.68.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=xeb@mail.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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