Bug 102502 - [netgraph] [patch] ifconfig name does't rename netgraph node in network.subr
Summary: [netgraph] [patch] ifconfig name does't rename netgraph node in network.subr
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2006-08-25 12:10 UTC by Aleksey Shirokih
Modified: 2022-11-20 17:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksey Shirokih 2006-08-25 12:10:24 UTC
ifconfig fxp0 name lan 
ifconfig lan 
lan: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=b<RXCSUM,TXCSUM,VLAN_MTU>
        inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255
        ether 00:07:e9:2a:a5:a0
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active

ngctl list 
 Name: fxp0             Type: ether           ID: 00000001   Num hooks: 1

as we can see ifconfig does not renames netgraph node 
so if we start mpd pppoe on lan iface it wil not find any interface to work

Fix: 

in /etc/network.subr add that litle patch 

# ifnet_rename
#       Rename all requested interfaces.
#
ifnet_rename()
{

        _ifn_list="`ifconfig -l`"
        [ -z "$_ifn_list" ] && return 0
        for _if in ${_ifn_list} ; do
                eval _ifname=\$ifconfig_${_if}_name
                if [ ! -z "$_ifname" ]; then
                        ifconfig $_if name $_ifname
                        #olc patch 
                        /usr/sbin/ngctl name $_if: $_ifname
                fi
        done
        return 0
}

in c code i not well enougth so no fix avalaible
How-To-Repeat: please watch higher
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2006-08-26 00:06:19 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-rc

Over to maintainer(s).
Comment 2 ru freebsd_committer 2006-08-26 15:26:25 UTC
On Fri, Aug 25, 2006 at 11:05:02AM +0000, Aleksey Shirokih wrote:
> 
> >Number:         102502
> >Category:       conf
> >Synopsis:       ifconfig name does't rename netgraph node
> 
ng_ether(4) creates all nodes when it's loaded, or when a new
interface is attached, and it *attempts* to name a node with
its interface's name.  This is not guaranteed though.

If you need to rename interfaces, you can load ng_ether module
*after* doing the renames.  It's not ideal, e.g., it'll still
require manual intervention if a new interface is plugged, but
I don't think that automatic renaming of nodes should happen,
unconditionally.


Cheers,
-- 
Ruslan Ermilov
ru@FreeBSD.org
FreeBSD committer
Comment 3 Gleb Smirnoff freebsd_committer 2006-08-28 10:28:18 UTC
On Sat, Aug 26, 2006 at 06:26:25PM +0400, Ruslan Ermilov wrote:
R> > >Number:         102502
R> > >Category:       conf
R> > >Synopsis:       ifconfig name does't rename netgraph node
R> > 
R> ng_ether(4) creates all nodes when it's loaded, or when a new
R> interface is attached, and it *attempts* to name a node with
R> its interface's name.  This is not guaranteed though.
R> 
R> If you need to rename interfaces, you can load ng_ether module
R> *after* doing the renames.  It's not ideal, e.g., it'll still
R> require manual intervention if a new interface is plugged, but
R> I don't think that automatic renaming of nodes should happen,
R> unconditionally.

I doubt that the problem shouldn't be fixed.

And this is a duplicate of kern/92270.

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE
Comment 4 Brooks Davis freebsd_committer 2006-08-28 13:49:02 UTC
Responsible Changed
From-To: freebsd-rc->freebsd-net

While the proposed workaround is in network.subr, it's not committable 
and the real issue is in the kernel.
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:47 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 6 Graham Perrin freebsd_committer 2022-10-17 12:40:54 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>
Comment 7 Aleksandr Fedorov freebsd_committer 2022-11-20 17:37:00 UTC
I think thi bug should be closed.

root@xenon:/home/XeNoN # ifconfig tap create
tap0
root@xenon:/home/XeNoN # ngctl ls
There are 5 total nodes:
  Name: ngeth0          Type: eiface          ID: 00000002   Num hooks: 1
  Name: ngeth1          Type: eiface          ID: 00000004   Num hooks: 1
  Name: re0             Type: ether           ID: 00000006   Num hooks: 0
  Name: tap0            Type: ether           ID: 0000000a   Num hooks: 0
  Name: ngctl44711      Type: socket          ID: 0000000b   Num hooks: 0
root@xenon:/home/XeNoN # ifconfig tap0 name renamed0
renamed0
root@xenon:/home/XeNoN # ngctl ls
There are 5 total nodes:
  Name: ngeth0          Type: eiface          ID: 00000002   Num hooks: 1
  Name: ngeth1          Type: eiface          ID: 00000004   Num hooks: 1
  Name: re0             Type: ether           ID: 00000006   Num hooks: 0
  Name: renamed0        Type: ether           ID: 0000000a   Num hooks: 0
  Name: ngctl44841      Type: socket          ID: 0000000c   Num hooks: 0
root@xenon:/home/XeNoN # 

ng_ether:

*
 * Interface arrival notification handler.
 * The notification is produced in two cases:
 *  o a new interface arrives
 *  o an existing interface got renamed
 * Currently the first case is handled by ng_ether_attach via special
 * hook ng_ether_attach_p.
 */
static void
ng_ether_ifnet_arrival_event(void *arg __unused, struct ifnet *ifp)
{
	char name[IFNAMSIZ];
	node_p node;

	/* Only ethernet interfaces are of interest. */
	if (ifp->if_type != IFT_ETHER &&
	    ifp->if_type != IFT_L2VLAN &&
	    ifp->if_type != IFT_BRIDGE)
		return;

	/*
	 * Just return if it's a new interface without an ng_ether companion.
	 */
	node = IFP2NG(ifp);
	if (node == NULL)
		return;

	/* Try to give the node the same name as the new interface name */
	ng_ether_sanitize_ifname(ifp->if_xname, name);
	if (ng_name_node(node, name) != 0)
		log(LOG_WARNING, "%s: can't re-name node %s\n", __func__, name);
}