|
|
Log in / Subscribe / Register

Using sysfs for configuring wireless networking

Using sysfs for configuring wireless networking

Posted Jan 12, 2006 3:31 UTC (Thu) by neilbrown (subscriber, #359)
Parent article: Linux and wireless networking

Atomic, multi-parameter update is quite possible with sysfs. You just need a "go" button.

Define the semantics of "write" to you sysfs attributes to be "store this value somewhere safe for later use".

Then have an attribute somewhere to which you can write "go".
This validates all those stored-for-later-use values and if they appear valid they all get update atomically.

This would require some locking so you don't get two apps writing to all those attributes at once, but that is hardly rocket-science.


to post comments

Using sysfs for configuring wireless networking

Posted Jan 12, 2006 7:00 UTC (Thu) by akumria (guest, #7773) [Link] (4 responses)

Let's imagine that the program crashes in-between writing the new values and hitting the 'go' button.

Wouldn't that mean that I would not be able to determine the current values of various settings?

Using sysfs for configuring wireless networking

Posted Jan 12, 2006 7:09 UTC (Thu) by neilbrown (subscriber, #359) [Link] (2 responses)

A fair point.

As the new settings have not yet come into effect, there is no particular value in finding out what they are. But it would be useful to be able to revert any partial setting of these values.

So that attribute where you write 'go' to effect the new values: Also allow 'reset' to be written which reverts all the stored-for-later-use values to the currently active values.

Ofcourse this could be achived by simply reading each attribute and writing the value back again, but that it somewhat ugly.

There is a thing called 'configfs' in -mm which is meant to be able to provide this multiple-values-at-once thing, but when I considerred using it for something, it turned out to be too special purpose. The same thing can be achieved in sysfs with a bit of creativity, and I think it fits better there.

Using sysfs for configuring wireless networking

Posted Jan 12, 2006 13:58 UTC (Thu) by bronson (subscriber, #4806) [Link] (1 responses)

That's starting to sound fairly brutal, don't you think? The cure might be worse than the disease.

I realize one of the key features of sysfs is that there's one value per file (try to avoid the mess that became /proc), but lack of atomic updates seems a rather fundamental limitation. What about writing multiple values to a write-only file?

echo "essid=bug;key=gazpacho" > /sys/class/net/eth1/config

Escaping would be required, of course, but that's easily solved.

I don't understand why a netlink socket would be an improvement... It requires parsing, like /proc, but is not user-configurable, like ioctls. It's the worst of both worlds!

Using sysfs for configuring wireless networking

Posted Jan 12, 2006 13:59 UTC (Thu) by nix (subscriber, #2304) [Link]

If the size of that multi-value lump is bigger than a page, write() is not necessarily atomic either.

Using sysfs for configuring wireless networking

Posted Jan 14, 2006 12:38 UTC (Sat) by fergal (guest, #602) [Link]

t = open(">/sys/blah/transaction")
... # write lots of new values
write(t, "commit")
close(t)

write(t, "rollback") or just closing the filehandle without writing "commit" would cause the new values to be discarded. Until the commit, everything else sees the old values. No danger from crashing programs, just kill them and start a new transaction. There are issues about concurrent updates to multiple parts of /sys but that'll be true in any system that provides atomic updates for multiple values.

Using sysfs for configuring wireless networking

Posted Jan 13, 2006 3:58 UTC (Fri) by gregkh (subscriber, #8) [Link] (1 responses)

> Atomic, multi-parameter update is quite possible with sysfs.
> You just need a "go" button.

But it's much easier to do with configfs, which is why it was created :)

Using sysfs for configuring wireless networking

Posted Jan 13, 2006 4:28 UTC (Fri) by neilbrown (subscriber, #359) [Link]

Configfs seems to be designed for initial configuration.
  1. you create a directory under '/config/scratch' (or some similar name). It magically has a bunch of attribute files in it.
  2. you fill values into those attribute files
  3. you rename "/config/scratch/whatever" to "/config/active/whatever" (names might be wrong) and suddenly "whatever" becomes live.

This doesn't seem to allow for reconfiguration. e.g. I want to change these three attributes atomically.

It also means that all the attributes appear under configfs for initial configuration, and may well need to appear in sysfs as well for monitoring/maintenance if they might change after initialisation. This is untidy.

In short, configfs seems to draw an unnatural distinction between initial configuration and ongoing maintenance, whereas I believe these should be indistinguishable.

The idea of using "mkdir" to create a new object is a nice one. It is a shame it cannot (does not) live directly in sysfs.

Using sysfs for configuring wireless networking

Posted Jan 19, 2006 8:51 UTC (Thu) by georgm (subscriber, #19574) [Link]

I like this idea, but I would change it a bit (to also solve the state thing mentioned in this thread:

Yo have different folders for different configuration sets (one for each configuration) and a folder called current.

You change values in the configuration folders (e.g. one for home, one for work). If you finished, you do an "echo home > config_in_use" or something like that and the values of this folder are copied to current.

current is no symlink to solve the problem, if something crashes between changing and applying. So the current state could always be read from folder current.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds