Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
TIP: Complete network stack without net.* scripts
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4, 5, 6  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Sun Aug 11, 2013 7:25 pm    Post subject: Reply with quote

smartass wrote:
VinzC, I use rfkill because AFAIK it can save power (may not be true for all cards). I recommend you assign a special key you don't use very often to issue rfkill through your WM or DE.

Not required. IIRC unloading the kernel module (iwlwifi) is enough to stop the wireless adapter (at least on my machine). As far as power is concerned the video adapter (Radeon) consumes far more than the wifi card, alas, which shows a negligible consumption in comparison. [OT: That's why I'm looking forward to 3.11 and DPM for ATI cards. But that's another story.]
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Mon Aug 19, 2013 9:53 am    Post subject: Reply with quote

I would just like to say thanks to VincZ for documenting and promoting what I originally set out to do with the OpenRC network (not the net.*) script and dhcpcd.
Basically, configure conf.d/network to brink up the link (bridging, bonding, authentication, etc) and let dhcpcd handle everything else.

Of note re wpa_supplicant, dhcpcd-6 will start (and stop) wpa_supplicant if /etc/wpa_supplicant.conf exists by itself.
This is handy because I can now plug and unplug a USB wifi card and It Just Works :)

No need for udev, ifplugd, NM or anything else.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
smartass
Apprentice
Apprentice


Joined: 04 Jul 2011
Posts: 189
Location: right behind you ... (you did turn around, didn't you?)

PostPosted: Mon Aug 19, 2013 11:32 am    Post subject: Reply with quote

UberLord wrote:

Of note re wpa_supplicant, dhcpcd-6 will start (and stop) wpa_supplicant if /etc/wpa_supplicant.conf exists by itself.
This is handy because I can now plug and unplug a USB wifi card and It Just Works :)

No need for udev, ifplugd, NM or anything else.
I appreciate that you've added so many features, but isn't it a bit too far against the unixy way of having one tool do its job well and do only that job?

OTOH, it's incredible that you've managed to this on your own in one tool and the people at RH have been failing to make it so simple and automagic for years :D

But seriously, isn't it a bit close to reinventing the wheel?
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Mon Aug 19, 2013 11:49 am    Post subject: Reply with quote

smartass wrote:
UberLord wrote:

Of note re wpa_supplicant, dhcpcd-6 will start (and stop) wpa_supplicant if /etc/wpa_supplicant.conf exists by itself.
This is handy because I can now plug and unplug a USB wifi card and It Just Works :)

No need for udev, ifplugd, NM or anything else.
I appreciate that you've added so many features, but isn't it a bit too far against the unixy way of having one tool do its job well and do only that job?



Not at all, when you view that the job of dhcpcd is just to configure network interfaces - it's not just a DHCP client.
And it does configure network interfaces very very well :)

OK, interacting so directly with wpa_supplicant is a little out of scope as dhcpcd doesn't really want to manage link configuration BUT it's a great example of how the hook scripts work.
The main reason why I included it is for the benefit of the BSD systems I also use where the user is entirely expected to script hotplugging, unlike say in Gentoo where this is achieved via udev and OpenRC automatically.

Quote:

OTOH, it's incredible that you've managed to this on your own in one tool and the people at RH have been failing to make it so simple and automagic for years :D

But seriously, isn't it a bit close to reinventing the wheel?


Thanks :)

It's not re-inventing the wheel at all. It's about making the wheel better with less maintenance.
Think about how many different parts other systems have, now think about many different parts dhcpcd has.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Mon Aug 19, 2013 6:26 pm    Post subject: Reply with quote

UberLord wrote:
I would just like to say thanks to VincZ for documenting and promoting what I originally set out to do with the OpenRC network (not the net.*) script and dhcpcd. [...]

It's my pleasure, Roy, totally.

Even after hacking the network stack and creating my own set of tools I still felt like I had underused dhcpcd all those years. So I dug a little and decided to share my findings. And I have to admit it is a remarkable tool of simplicity.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8704
Location: ~Brussels - Belgique

PostPosted: Tue Sep 17, 2013 10:13 am    Post subject: Reply with quote

Hello,

I tried the tip, and I would like to migrate preup() and postup() hooks I have in /etc/conf.d/net, especially the SSID variable. But moving preup() and postup() from net to network don't help.

Any idea? ;)
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
smartass
Apprentice
Apprentice


Joined: 04 Jul 2011
Posts: 189
Location: right behind you ... (you did turn around, didn't you?)

PostPosted: Tue Sep 17, 2013 11:54 am    Post subject: Reply with quote

XavierMiller, you could use the hooks framework that dhcpcd offers. See the manual page of
Code:
dhcpcd-run-hooks
according to
Code:
dhcpcd --variables
the ssid variable can be set, so you could add a case construct for that.
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8704
Location: ~Brussels - Belgique

PostPosted: Tue Sep 17, 2013 12:19 pm    Post subject: Reply with quote

Thank you, I will take a look tonight ;)
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
Dr.Willy
Guru
Guru


Joined: 15 Jul 2007
Posts: 547
Location: NRW, Germany

PostPosted: Tue Sep 17, 2013 2:59 pm    Post subject: Reply with quote

wireless specific actions can also be triggered via "wpa_cli -a <script>"
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8704
Location: ~Brussels - Belgique

PostPosted: Tue Sep 17, 2013 6:02 pm    Post subject: Reply with quote

Hello,

I have an other issue : wpa_supplicant is not run on hotplugged wlan interfaces (usb sticks). If I restart the service, the USB stick is activated.
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Tue Sep 17, 2013 6:26 pm    Post subject: Reply with quote

XavierMiller wrote:
I have an other issue : wpa_supplicant is not run on hotplugged wlan interfaces (usb sticks). If I restart the service, the USB stick is activated.

Have you installed >=dhcpcd-6.0 ?
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8704
Location: ~Brussels - Belgique

PostPosted: Tue Sep 17, 2013 6:30 pm    Post subject: Reply with quote

Yup, I'm running ~arch

Code:
[ebuild   R    ] net-misc/dhcpcd-6.0.5-r1  USE="-ipv6" 0 kB


PS: if I pollute that thread, I could open a new one.
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8704
Location: ~Brussels - Belgique

PostPosted: Thu Sep 19, 2013 10:18 am    Post subject: Reply with quote

I will take a look at this wpa_supplicant hook : http://fossies.org/linux/misc/dhcpcd-6.0.5.tar.gz:a/dhcpcd-6.0.5/dhcpcd-hooks/10-wpa_supplicant

EDIT: found! The hook looks /etc/wpa_supplicant.conf which is not correct in Gentoo. If I create a symlink, wpa_supplicant is managed by dhcpcd
I will file a bug ;)
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Thu Sep 19, 2013 11:26 am    Post subject: Reply with quote

XavierMiller wrote:
I will take a look at this wpa_supplicant hook : http://fossies.org/linux/misc/dhcpcd-6.0.5.tar.gz:a/dhcpcd-6.0.5/dhcpcd-hooks/10-wpa_supplicant

EDIT: found! The hook looks /etc/wpa_supplicant.conf which is not correct in Gentoo. If I create a symlink, wpa_supplicant is managed by dhcpcd
I will file a bug ;)

IMHO the bug is not needed as it looks like a configuration parameter. Try setting wpa_supplicant_conf in dhcpcd.conf to the real path and see how it works.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8704
Location: ~Brussels - Belgique

PostPosted: Thu Sep 19, 2013 11:38 am    Post subject: Reply with quote

it also works :)

For the moment, I write my hook to set-up some hostpot scripts and other stuff, and it seems to work.

EDIT: it works !
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6050
Location: Removed by Neddy

PostPosted: Fri Sep 20, 2013 12:35 pm    Post subject: Reply with quote

one question. Why?
_________________
Quote:
Removed by Chiitoo
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


Joined: 23 Jul 2004
Posts: 8704
Location: ~Brussels - Belgique

PostPosted: Fri Sep 20, 2013 12:44 pm    Post subject: Reply with quote

Because I don't want to need nice GUIs, which are unnecessary to configure 2-3 networks. And so, I avoid unnecessary bullshit that change every 2 years (HAL, Systemd, *kit).

And I need to configure 2 things depending on the discovered network
- set DISTCC features at home, when the distcc server is up and running
- execute a logon script on hotspot used at work

Because KISS.
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Fri Sep 20, 2013 1:59 pm    Post subject: Reply with quote

Naib wrote:
one question. Why?

XavierMiller wrote:
Because I don't want to need nice GUIs, which are unnecessary to configure 2-3 networks. And so, I avoid unnecessary bullshit that change every 2 years (HAL, Systemd, *kit).
[...]
Because KISS.

Ditto.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
Incomplet
n00b
n00b


Joined: 12 Apr 2012
Posts: 43

PostPosted: Sat Mar 22, 2014 5:16 pm    Post subject: Reply with quote

dhcpcd is perhaps the most awesome piece of software that I've ever come across. It's awesome even if you don't configure it, and more awesome when you do. It's also the most reliable network manager that I have ever used, free or otherwise. The network manager on OSX would randomly stop working and if the network went screwy there was no chance of bringing it back without a restart (or two). On windows the manager does screwy things sometimes, and you never know what kind of garbage MS has in the pipe at any time. dhcpcd, on the other hand, has always "just worked" for me, no matter what (although the rest of my system is another story..). The wind will knock out all my powerlines and bring my machine down before dhcpcd will give me problems, and I can hardly blame it for not working then.

The mere fact that it's still being improved astounds me. If only gnome had that sort of accountability..
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Sat Mar 22, 2014 7:47 pm    Post subject: Reply with quote

8) :oops: 8)
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Incomplet
n00b
n00b


Joined: 12 Apr 2012
Posts: 43

PostPosted: Sat Mar 22, 2014 9:26 pm    Post subject: Reply with quote

aand, now testing with no net.* scripts, and it looks to be working as advertised. At first I thought it hadn't worked, since with background and quiet I couldn't even see the entry in openrc. But no, fully automagical.

How on earth did you do that, anyway? Test driven development? Magic? (the only options I can come up with)
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Sat Mar 22, 2014 11:41 pm    Post subject: Reply with quote

Magic is not depending on the FOTM middleware. dhcpcd communicates only via libc and listens only via the kernel (ok, dhcpcd does have a udev plugin so that udev can do its pointless device naming). These channels of communication are defined by agreed standards, such as POSIX and in the case of Linux, netlink. But this is not magic, this is common sense.

From my Debian amd64 box
Code:

roy@uberpc:~/src/dhcpcd$ size /sbin/dhcpcd /sbin/dhclient /usr/sbin/NetworkManager
   text      data       bss       dec       hex   filename
 194982      1544       432    196958     3015e   /sbin/dhcpcd
1620973     24576     45264   1690813    19ccbd   /sbin/dhclient
1012178     22656      3016   1037850     fd61a   /usr/sbin/NetworkManager


And that's not including any GUI components. Magic :)
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Sun Mar 23, 2014 5:53 pm    Post subject: Reply with quote

Since my favourite Troll has been invited (hehe ;-) ) I'd just add onto the MS weirdness that I've always been amazed at why on Earth Microsoft decided to make interface precedence but *manual* (interfaces are sorted... alphabetically). We have the issue systematically at work when we receive pre-installed machines or when reinstalling them: wireless interfaces always take precedence over the wired interfaces and you have to manually reorder them, i.e. move the wired interface to the top of the list.

On Linux it is automatic. Besides, traffic automatically switches to the fastest interface when you plug the cable, no need to restart existing connections.

Magic sometimes relates to common sense.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
Incomplet
n00b
n00b


Joined: 12 Apr 2012
Posts: 43

PostPosted: Sun Mar 23, 2014 9:22 pm    Post subject: Reply with quote

@RM: Yeah, I've noticed that upstream sucks. It's really sad if the rest of gnu/linux could be that good if only certain people weren't trying to play monopolyOS. It's also amazing in a way, given all the limitations of C.

@Vinz: *sigh* dhcpcd also automatically stops the wireless card/driver in that situation too, doesn't it? What is it people have against sensibility, anyway?
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Sun Mar 23, 2014 9:41 pm    Post subject: Reply with quote

Incomplet wrote:
@Vinz: *sigh* dhcpcd also automatically stops the wireless card/driver in that situation too, doesn't it? What is it people have against sensibility, anyway?


No, dhcpcd just changes the default route to go via wired.
If both are on the same subnet (which they really shouldn't be) then it will change the subnet route also on BSDs = on Linux there is no need thanks to routing metrics.

The only thing dhcpcd will stop is wpa_supplicant if the interface goes away.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3, 4, 5, 6  Next
Page 2 of 6

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum