From: Eric Dumazet <eric.dumazet@gmail.com>
To: James Chapman <jchapman@katalix.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH v2 10/12] l2tp: Add L2TP ethernet pseudowire support
Date: Mon, 29 Mar 2010 13:05:10 +0200 [thread overview]
Message-ID: <1269860710.2164.19.camel@edumazet-laptop> (raw)
In-Reply-To: <20100329095731.30460.19852.stgit@bert.katalix.com>
Le lundi 29 mars 2010 à 10:57 +0100, James Chapman a écrit :
> +static struct l2tp_session *l2tp_eth_session_find_by_ifname(struct net *net, char *ifname)
> +{
> + struct net_device *dev;
> +
> + dev = dev_get_by_name(net, ifname);
> + if (dev) {
> + struct l2tp_eth *priv = netdev_priv(dev);
> + return priv->session;
> + }
> +
> + return NULL;
> +}
> +
Not clear to me if caller of l2tp_eth_session_find_by_ifname()
is able to do dev_put(dev);
l2tp_eth_create() ->
> +static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg)
> +{
> + struct net_device *dev;
> + char name[IFNAMSIZ];
> + struct l2tp_tunnel *tunnel;
> + struct l2tp_session *session;
> + struct l2tp_eth *priv;
> + struct l2tp_eth_sess *spriv;
> + int rc;
> + struct l2tp_eth_net *pn;
> +
> + tunnel = l2tp_tunnel_find(net, tunnel_id);
> + if (!tunnel) {
> + rc = -ENODEV;
> + goto out;
> + }
> +
> + session = l2tp_session_find(net, tunnel, session_id);
> + if (session) {
> + rc = -EEXIST;
> + goto out;
> + }
> +
> + if (cfg->ifname) {
> + session = l2tp_eth_session_find_by_ifname(net, cfg->ifname);
> + if (session) {
> + rc = -EEXIST;
> + goto out;
> + }
> + strlcpy(name, cfg->ifname, IFNAMSIZ);
> + } else
> + strcpy(name, L2TP_ETH_DEV_NAME);
> +
> + session = l2tp_session_create(sizeof(*spriv), tunnel, session_id,
> + peer_session_id, cfg);
> + if (!session) {
> + rc = -ENOMEM;
> + goto out;
> + }
> +
> + dev = alloc_netdev(sizeof(*priv), name, l2tp_eth_dev_setup);
> + if (!dev) {
> + rc = -ENOMEM;
> + goto out_del_session;
> + }
> +
> + dev_net_set(dev, net);
> + if (session->mtu == 0)
> + session->mtu = dev->mtu - session->hdr_len;
> + dev->mtu = session->mtu;
> + dev->needed_headroom += session->hdr_len;
> +
> + priv = netdev_priv(dev);
> + priv->dev = dev;
> + priv->session = session;
> + INIT_LIST_HEAD(&priv->list);
> +
> + priv->tunnel_sock = tunnel->sock;
> + session->recv_skb = l2tp_eth_dev_recv;
> + session->session_close = l2tp_eth_delete;
> +#ifdef CONFIG_PROC_FS
> + session->show = l2tp_eth_show;
> +#endif
> +
> + spriv = l2tp_session_priv(session);
> + spriv->dev = dev;
> +
> + rc = register_netdev(dev);
> + if (rc < 0)
> + goto out_del_dev;
> +
> + /* Must be done after register_netdev() */
> + strlcpy(session->ifname, dev->name, IFNAMSIZ);
> +
> + dev_hold(dev);
> + pn = l2tp_eth_pernet(dev_net(dev));
> + write_lock(&pn->l2tp_eth_lock);
> + list_add(&priv->list, &pn->l2tp_eth_dev_list);
> + write_unlock(&pn->l2tp_eth_lock);
> +
> + return 0;
> +
> +out_del_dev:
> + free_netdev(dev);
> +out_del_session:
> + l2tp_session_delete(session);
I cant see the dev_put() here
> +out:
> + return rc;
> +}
next prev parent reply other threads:[~2010-03-29 11:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-29 9:56 [PATCH v2 00/12] l2tp: Introduce L2TPv3 support James Chapman
2010-03-29 9:56 ` [PATCH v2 01/12] l2tp: Relocate pppol2tp driver to new net/l2tp directory James Chapman
2010-03-29 9:56 ` [PATCH v2 02/12] l2tp: Split pppol2tp patch into separate l2tp and ppp parts James Chapman
2010-03-29 10:18 ` Eric Dumazet
2010-03-29 9:56 ` [PATCH v2 03/12] ppp: Add ppp_dev_name() exported function James Chapman
2010-03-29 9:57 ` [PATCH v2 04/12] l2tp: Add ppp device name to L2TP ppp session data James Chapman
2010-03-29 9:57 ` [PATCH v2 05/12] l2tp: Add L2TPv3 protocol support James Chapman
2010-03-29 9:57 ` [PATCH v2 06/12] l2tp: Update PPP-over-L2TP driver to work over L2TPv3 James Chapman
2010-03-29 9:57 ` [PATCH v2 07/12] l2tp: Add L2TPv3 IP encapsulation (no UDP) support James Chapman
2010-03-29 9:57 ` [PATCH v2 08/12] netlink: Export genl_lock() API for use by modules James Chapman
2010-03-29 9:57 ` [PATCH v2 09/12] l2tp: Add netlink control API for L2TP James Chapman
2010-03-29 9:57 ` [PATCH v2 10/12] l2tp: Add L2TP ethernet pseudowire support James Chapman
2010-03-29 11:05 ` Eric Dumazet [this message]
2010-03-29 12:10 ` James Chapman
2010-03-29 9:57 ` [PATCH v2 11/12] l2tp: Add support for static unmanaged L2TPv3 tunnels James Chapman
2010-03-29 10:40 ` Eric Dumazet
2010-03-29 10:52 ` James Chapman
2010-03-29 9:57 ` [PATCH v2 12/12] l2tp: Update documentation James Chapman
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=1269860710.2164.19.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=jchapman@katalix.com \
--cc=netdev@vger.kernel.org \
/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