kobject events questions
Subsystems (2)
Hi all,
I've been following the evolution of kobject events patch. This is because I'd like to implement a netfilter target that is able to send an event to userland using it.
There's a small description of it and some background in the netfilter mailing list:
http://lists.netfilter.org/pipermail/netfilter-devel/2004-August/016342.html
Now that the events are strictly associated with kobjects (the original patch had a way to send arbitrary events) I have two choices:
1) Send the events so that they are always associated with the network devices class_device kobject. I guess this would be quite clean way to do it, but it'd require adding a new signal type and would limit the iptables target to be associated always with a interface.
2) Create a device class that has virtual timer devices that trigger events (ie. /sys/class/utimer). Each timer could have some attributes (like expired, expire_time, etc.) and would emit "change" signals whenever timer expires.
I'd like to hear what you think of the thing I'm trying to do?
And especially how "bad" idea the option 2 is (since the new class might not be useful for others)?
Any ideas how this could be done better?
- Timo
Quoted 10 lines · Timo Teräs
1) Send the events so that they are always associated with the network devices
class_devicekobject. I guess this would be quite clean way to do it, but it'd require adding a new signal type and would limit the iptables target to be associated always with a interface.2) Create a device class that has virtual timer devices that trigger events (ie.
/sys/class/utimer). Each timer could have some attributes (like expired,expire_time, etc.) and would emit "change" signals whenever timer expires.
Quoted 4 lines
I'd like to hear what you think of the thing I'm trying to do?
And especially how "bad" idea the option 2 is (since the new class might not be useful for others)?
Well, #1 is the intention and spirit of the kevent system.
And adding a new signal type is fine.
So the only downside is that the table to interface association thing. I have no idea how big an issue that is for you.
You could of course create a new kobject, ala #2, but that does not seem optimal if the object is otherwise worthless. I don't think that you should create a new class. Better to put something under /sys/net related to what you are doing.
Robert Love
Quoted 11 lines · Robert Love
Quoted 3 lines · Timo Teräs
1) Send the events so that they are always associated with the network devices
class_devicekobject. I guess this would be quite clean way to do it, but it'd require adding a new signal type and would limit the iptables target to be associated always with a interface.2) Create a device class that has virtual timer devices that trigger events (ie.
/sys/class/utimer). Each timer could have some attributes (like expired,expire_time, etc.) and would emit "change" signals whenever timer expires.Well, #1 is the intention and spirit of the kevent system.
And adding a new signal type is fine.
So the only downside is that the table to interface association thing. I have no idea how big an issue that is for you.
I'm just a bit dubious about adding new signals since they are hardcoded in the kernel. It's a time consuming process to add new signals (either for development build or for official kernels). This is one of the reasons I liked more about the original kevent patch. Wouldn't simple #defines have been enough for signal names?
Quoted 4 lines
You could of course create a new kobject, ala #2, but that does not seem optimal if the object is otherwise worthless. I don't think that you should create a new class. Better to put something under
/sys/netrelated to what you are doing.
I thought quite a bit about to where add my kobjects. I couldn't find a /sys/net on my current system (am I missing some config option?). If you mean /sys/class/net aren't all kobject in there supposed to be of same type (namely class_device associated with net_device). Of course I could add them under some interface, but then again my iptables rules would have to be interface specific and this is the thing I'm trying to avoid in this approach. Adding to /sys would be an overkill as it'd require implementing a subsystem. And I couldn't find any other suitable place so ended up making a new class.
I actually made some test code to add a new class and it's relatively simple. But I guess it isn't really useful if I'd be the only user. Maybe it could have some features that'd make it more generic?
Of course, I could use the "connector" patch that Greg pointed, but I'd still like more the kevent approach. Namely, it'd make my userland app much simpler.
Cheers,
Timo
Quoted 16 lines · Timo Ter??s
Quoted 15 lines · Robert Love
Quoted 9 lines · Timo Ter??s
1) Send the events so that they are always associated with the network devices
class_devicekobject. I guess this would be quite clean way to do it, but it'd require adding a new signal type and would limit the iptables target to be associated always with a interface.2) Create a device class that has virtual timer devices that trigger events (ie.
/sys/class/utimer). Each timer could have some attributes (like expired,expire_time, etc.) and would emit "change" signals whenever timer expires.Well, #1 is the intention and spirit of the kevent system.
And adding a new signal type is fine.
Quoted 8 lines
Quoted 2 lines
So the only downside is that the table to interface association thing. I have no idea how big an issue that is for you.
I'm just a bit dubious about adding new signals since they are hardcoded in the kernel. It's a time consuming process to add new signals (either for development build or for official kernels). This is one of the reasons I liked more about the original kevent patch. Wouldn't simple #defines have been enough for signal names?
What's the difference between a #define and a enum? We want these to be well known, and correct. A enum gives us that.
Quoted 9 lines
Quoted 4 lines
You could of course create a new kobject, ala #2, but that does not seem optimal if the object is otherwise worthless. I don't think that you should create a new class. Better to put something under
/sys/netrelated to what you are doing.I thought quite a bit about to where add my kobjects. I couldn't find a
/sys/neton my current system (am I missing some config option?). If you mean/sys/class/netaren't all kobject in there supposed to be of same type (namelyclass_deviceassociated withnet_device).
Yes, that is what /sys/class/net contains.
Good luck,
greg k-h
Quoted 8 lines · ext Greg KH
Quoted 5 lines
I'm just a bit dubious about adding new signals since they are hardcoded in the kernel. It's a time consuming process to add new signals (either for development build or for official kernels). This is one of the reasons I liked more about the original kevent patch. Wouldn't simple #defines have been enough for signal names?
What's the difference between a #define and a enum? We want these to be well known, and correct. A enum gives us that.
I was a bit ambiguous. I meant #defines with string literals. That would have assured correct signal names. I guess to have them all well known justifies for enums (even though it makes adding new ones a bit more difficult).
Thanks,
Timo
Quoted 7 lines · Teras Timo (EXT-YomiGroup/Helsinki)
Quoted 6 lines · ext Greg KH
Quoted 5 lines
I'm just a bit dubious about adding new signals since they are hardcoded in the kernel. It's a time consuming process to add new signals (either for development build or for official kernels). This is one of the reasons I liked more about the original kevent patch. Wouldn't simple #defines have been enough for signal names?
Quoted 7 lines
Quoted 2 lines
What's the difference between a #define and a enum? We want these to be well known, and correct. A enum gives us that.
I was a bit ambiguous. I meant #defines with string literals. That would have assured correct signal names. I guess to have them all well known justifies for enums (even though it makes adding new ones a bit more difficult).
That's the point. It should "be difficult" in that you need to present a valid reason to the whole kernel community as to why a new event needs to be added. But if you make a point that others agree with, then there should be no problem in adding it.
thanks,
greg k-h
Quoted 4 lines · ext Greg KH
That's the point. It should "be difficult" in that you need to present a valid reason to the whole kernel community as to why a new event needs to be added. But if you make a point that others agree with, then there should be no problem in adding it.
Ok. Now that I can implement my iptables plugin I need either:
1) A new event: something like "went idle". Which would be sent from the class_device kobject of related network interface.
or
2) I could use the class interface system to add an kobject (instead of writing a new class) for each network devices class_device. But to accomplish this I have to be able to register interfaces with net_class defined net-sysfs.c. See applied patch. It's provides similar functions as scsi layer (see scsi_register_interface).
Which one would be better choice? At least the option #2 is general purpose and some others might find it useful too. To whom/where I should send it?
- Timo
net/core/net-sysfs.c +8 -0
@@ -448,3 +448,11 @@ {return class_register (&net_class); } + +int netdev_register_interface (struct class_interface *intf) +{ + intf->class = &net_class; +return class_interface_register (intf); +} + +EXPORT_SYMBOL_GPL (netdev_register_interface);
include/linux/netdevice.h +6 -0
@@ -953,6 +953,12 @@extern char *net_sysctl_strdup (const char *s);#endif +#ifdef CONFIG_SYSFS +extern int netdev_register_interface (struct class_interface *intf); +#define netdev_unregister_interface (intf) \ + class_interface_unregister(intf) +#endif +#endif /* __KERNEL__ */ #endif /* _LINUX_DEV_H */
Quoted 18 lines · Timo Ter?s
Hi all,
I've been following the evolution of kobject events patch. This is because I'd like to implement a netfilter target that is able to send an event to userland using it.
There's a small description of it and some background in the netfilter mailing list:
http://lists.netfilter.org/pipermail/netfilter-devel/2004-August/016342.htmlNow that the events are strictly associated with kobjects (the original patch had a way to send arbitrary events) I have two choices:
1) Send the events so that they are always associated with the network devices
class_devicekobject. I guess this would be quite clean way to do it, but it'd require adding a new signal type and would limit the iptables target to be associated always with a interface.
Quoted 6 lines
2) Create a device class that has virtual timer devices that trigger events (ie.
/sys/class/utimer). Each timer could have some attributes (like expired,expire_time, etc.) and would emit "change" signals whenever timer expires.I'd like to hear what you think of the thing I'm trying to do?
Have you looked at the "connector" patch from Evgeniy Polyakov <[email protected]> that was posted to Linux kernel? After that goes in, the kevent code will probably be tweaked to use that interface.
thanks,
greg k-h