--- sys/netgraph/ng_iface.c.orig	Sat May  5 12:38:26 2001
+++ sys/netgraph/ng_iface.c	Sat May  5 17:31:26 2001
@@ -62,9 +62,11 @@
 #include <sys/socket.h>
 #include <sys/syslog.h>
 #include <sys/libkern.h>
+#include <sys/ctype.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
+#include <net/if_dl.h>
 #include <net/intrq.h>
 #include <net/bpf.h>
 
@@ -157,6 +159,13 @@
 	},
 	{
 	  NGM_IFACE_COOKIE,
+	  NGM_IFACE_SET_IFNAME,
+	  "setifname",
+	  &ng_iface_ifname_type,
+	  NULL
+	},
+	{
+	  NGM_IFACE_COOKIE,
 	  NGM_IFACE_POINT2POINT,
 	  "point2point",
 	  NULL,
@@ -641,6 +650,57 @@
 			arg = (struct ng_iface_ifname *)resp->data;
 			snprintf(arg->ngif_name, sizeof(arg->ngif_name),
 			    "%s%d", ifp->if_name, ifp->if_unit);
+			break;
+		    }
+
+		case NGM_IFACE_SET_IFNAME:
+		    {
+			struct ng_iface_ifname *arg = 
+			       (struct ng_iface_ifname *)msg->data;
+			char *str;
+			int unit;
+			int s;
+			struct ifnet * ifpr = NULL;
+
+			/* Deny request if interface is UP */
+			if ((ifp->if_flags & IFF_UP) != 0) {
+			  error = EBUSY;
+			  break;
+			}
+			
+
+			for (str = arg->ngif_name + strlen(arg->ngif_name) - 1;
+			     (str > arg->ngif_name) && isdigit(*str); str--);
+			
+			if (str == arg->ngif_name) {
+			  error = EINVAL;
+			  break;
+			}
+
+			str++;
+			unit = strtoul(str, NULL, 10);
+			*str = '\0';
+
+			/* check for existing interface with same name */
+			s = splimp();
+			TAILQ_FOREACH(ifpr, &ifnet, if_link) 
+			  if ((strcmp(ifpr->if_name, arg->ngif_name) == 0) && (ifpr->if_unit == unit)) {
+			    error = EEXIST;
+			    break;
+			  }
+			
+			splx(s);
+			if (error) break;
+			
+			MALLOC(ifp->if_name, char *, strlen(arg->ngif_name) + 1, M_NETGRAPH, M_NOWAIT);
+			s = splimp();
+			strcpy(ifp->if_name, arg->ngif_name);
+			ifp->if_unit = unit;
+			splx(s);
+			
+			if_detach(ifp);
+			if_attach(ifp);
+			
 			break;
 		    }
 
--- sys/netgraph/ng_iface.h.orig	Sat May  5 12:38:33 2001
+++ sys/netgraph/ng_iface.h	Sat May  5 14:21:09 2001
@@ -70,6 +70,7 @@
 	NGM_IFACE_GET_IFNAME = 1,	/* returns struct ng_iface_ifname */
 	NGM_IFACE_POINT2POINT,
 	NGM_IFACE_BROADCAST,
+	NGM_IFACE_SET_IFNAME,           /* set interface name */
 };
 
 struct ng_iface_ifname {
