[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFLxGvy-UTUpNJVSqKuJPxmf4fni1T0bzbxKctTMTqmsGOiuFA@mail.gmail.com>
Date: Sun, 8 Mar 2015 15:07:09 +0100
From: Richard Weinberger <richard.weinberger@...il.com>
To: Ran Shalit <ranshalit@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: Re: dev_get_by_name example
On Sun, Mar 8, 2015 at 2:04 PM, Ran Shalit <ranshalit@...il.com> wrote:
> Hello,
>
> How should we use dev_get_by_name ?
> What should be the 1st parameter should it be a pointer ? (without
> allocation required) ?
The network namespace you want to use.
> struct net_device *dev_get_by_name(struct net *net, const char *name);
> I get an exception when using it for unallocated pointer in 1st
> argument, but succeeded with the following:
> ndev = dev_get_by_name(&init_net, "eth0");
> Is it alloweed to use init_net ?
Only if you want to do a lookup in the initial network namespace.
If you're in process context you better use the current network namespace.
But I don't know your use case.
--
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists