Re: ipconfig -i en2 NONE?
Re: ipconfig -i en2 NONE?
- Subject: Re: ipconfig -i en2 NONE?
- From: Vincent Lubet <email@hidden>
- Date: Wed, 4 Nov 2009 10:01:27 -0800
Godfrey,
Please note the SIOCPROTODETACH ioctl mentioned by Josh is marked PRIVATE which means that it behavior may change with any release of OS X...
Vincent
On Nov 3, 2009, at 9:37 PM, Josh Graessley wrote:
>
> Hi Godfrey,
>
> The following is based on code from the bootp project:
>
> static int
> siocprotodetach(const char * name)
> {
> int sockfd;
> struct ifreq ifr;
>
> sockfd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); // check that this didn't return -1
>
> bzero(&ifr, sizeof(ifr));
> strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
> ioctl(sockfd, SIOCPROTODETACH, &ifr); // check that this didn't return -1
> close(sockfd);
> }
>
> Good luck. If you need to detach IPv6 as well, you'll want to use the SIOCPROTODETACH_IN6 ioctl.
>
> -josh
>
> On Nov 1, 2009, at 10:10 PM, Godfrey van der Linden wrote:
>
>> G'day, Josh.
>>
>> Thanks for the clues. I'd really, really like to be able to develop from a ssh into the host machine; this allows me to do everything from the primary development system. I have found the ioctl you mentioned SIOCPROTODETACH but I'm frankly lost as to how to use it? It seems to require a socket but I'm nor really a network programmer. Can you give me a few hints ;-) I don't mind writing a bit of code that can automatically detach a protocol from an IOEthernetInterface(net_if?).
>>
>> Thanks
>>
>> Godfrey
>>
>> On 2009-11-02, at 13:10 , Josh Graessley wrote:
>>
>>>
>>> This may be caused by the IP protocol still being attached to the ethernet interface. When you run ifconfig en2 inet... and an IP address is attached to the interface, that implicitly attaches IP to the ethernet interface. If you instead set up a network service for the interface using the network preferences to assign the address, and then disable that service to remove the address, the ip configuration plug-in will perform an explicit attach when assigning the address and an explicit detach when you disable that service. That explicit protocol detach is the key to getting the interface to unload cleanly.
>>>
>>> Alternatively, you could write a command line tool to send the ioctl to detach the IP protocol from the ethernet interface. I can't recall the name of the ioctl.
>>>
>>> The protocol isn't automatically detached from the interface when the last address is removed for obscure reasons. So there is a reason, I just can't recall what it is or whether or not it's a good reason.
>>>
>>> -josh
>>>
>>> On Nov 1, 2009, at 5:37 PM, Godfrey van der Linden wrote:
>>>
>>>> While trying to debug a USB network kext I find that I can't unload as the dlil isn't being destroyed.
>>>>
>>>> Following the steps of the documentation.
>>>>
>>>> Steps to reproduce (using a pegasus USB enet, but the same steps are reproducable with the Air's ENET dongle)
>>>>
>>>> 1> Load the IOKit kext
>>>> 2> ifconfig en2 inet 192.168.1.2 netmask 255.255.255.0 up
>>>> 3> arp it on both machines
>>>> 4> Do some test, then...
>>>> 5> ipconfig set en2 NONE
>>>> 6> kextunload ... Fails still has references
>>>> 7> ifconfig -a (Still shows an active en2 interface?)
>>>>
>>>> This looks like a bug in Snow Leopard?
>>>>
>>>> Nothing I do will unload the kext even thought this is the documented techniques described in http://developer.apple.com/mac/library/documentation/DeviceDrivers/Conceptual/NetworkDriver/3_Tipsfolder/TipsonBringup.html
>>>>
>>>> Godfrey
>>>>
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Darwin-kernel mailing list (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>
>>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-kernel mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden