Re: [PATCH][RFC][ModemManager] udev rules: port to hwdb where applicable
On 22 Jul 2013 17:43, Dan Williams d...@redhat.com wrote: On Sat, 2013-07-20 at 01:53 +0200, Tom Gundersen wrote: Udev recently gained a hardware database, which is an efficent replacement for the kind of rules shipped with modemmanager. This patch ports all the relevant udev rules to hwdb format, which should significantly speed up the processing of usb add events. Which is nice, but it's significantly less clear and readable than the udev rules, unfortunately. Is there any way we can autogenerate the hwdb stuff from the udev rules and just install that instead, but keep editing the udev rules? I don't think it would be impossible, but at the same time I don't see how to do it in a reasonable and robust way. I'm cc'ing Kay in case he wants to prove me wrong. Another option would be to introduce a new, special purpose, intermediate language, see e.g. how media-player-info does it. However, are you sure it is worth the effort? We only have four different (and largely overlapping) patterns in use, so if we add the right documentation/comments at the top of all the rules files it should be easy enough to edit, don't you think? -t ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: [PATCH][RFC][ModemManager] udev rules: port to hwdb where applicable
On Tue, Jul 23, 2013 at 12:46 PM, Tom Gundersen t...@jklm.no wrote: On 22 Jul 2013 17:43, Dan Williams d...@redhat.com wrote: On Sat, 2013-07-20 at 01:53 +0200, Tom Gundersen wrote: Udev recently gained a hardware database, which is an efficent replacement for the kind of rules shipped with modemmanager. This patch ports all the relevant udev rules to hwdb format, which should significantly speed up the processing of usb add events. Which is nice, but it's significantly less clear and readable than the udev rules, unfortunately. Is there any way we can autogenerate the hwdb stuff from the udev rules and just install that instead, but keep editing the udev rules? I don't think it would be impossible, but at the same time I don't see how to do it in a reasonable and robust way. I'm cc'ing Kay in case he wants to prove me wrong. Another option would be to introduce a new, special purpose, intermediate language, see e.g. how media-player-info does it. However, are you sure it is worth the effort? We only have four different (and largely overlapping) patterns in use, so if we add the right documentation/comments at the top of all the rules files it should be easy enough to edit, don't you think? The modalias string is not the prettiest thing yeah, but it's how the kernel modules and all the rest works now. I guess it's just a matter of getting used to. Projects could maintain the data in any format that fits their need, sure, and export udev rule or hwdb files. It makes fixes and additions from users more complicated though, because they will probably send it in the hwdb format. There is currently no plan to ship a converter in upstream systemd though to convert udev rules to hwdb. Kay ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
nm-platform suspend/resume routing problem
Hi, didn't catch you on IRC, IMO the routing problem will be more general and suspend/resume only triggers it. In my opinion, setting interface down can trigger inconsistent cache state and we have to clear or maybe even refill the address/route cache when link down event is received. To handle this properly, a new automated test to check that would be needed. Also, more information about what protocol version the route was and what was its source may be needed. Cheers, Pavel ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: nm-platform suspend/resume routing problem
On Tue, 2013-07-23 at 17:40 -0400, Pavel Simerda wrote: Hi, didn't catch you on IRC, IMO the routing problem will be more general and suspend/resume only triggers it. In my opinion, setting interface down can trigger inconsistent cache state and we have to clear or maybe even refill the address/route cache when link down event is received. To handle this properly, a new automated test to check that would be needed. Also, more information about what protocol version the route was and what was its source may be needed. No problem, I posted a patch to the bug that seems to work around the issue. It appears that the kernel never sends RTM_DELROUTE events for an interface's routes (including the default route) when the interface goes down, but it does remove those routes from the routing table. Thus, even if the platform was listening to the kernel, it wouldn't see the default route removal events anyway. Note that I don't think there's a problem with RTM_DELADDR, just routes. I do see the RTM_DELADDR events when taking the interface down. Perhaps the kernel just expects userspace to know that when an interface goes !IFF_UP that all that interface's routes are now removed? That seems kinda odd, would be nice to have RTM_DELROUTE events whenever a route is deleted instead of deducing magic. Dan ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: [patch NetworkManager v2 2/6] add setting for team port
On Mon, 2013-07-15 at 09:46 +0200, Jiri Pirko wrote: Signed-off-by: Jiri Pirko j...@resnulli.us --- libnm-util/Makefile.am| 2 + libnm-util/libnm-util.ver | 5 ++ libnm-util/nm-connection.c| 17 libnm-util/nm-connection.h| 2 + libnm-util/nm-setting-team-port.c | 174 ++ libnm-util/nm-setting-team-port.h | 76 + 6 files changed, 276 insertions(+) create mode 100644 libnm-util/nm-setting-team-port.c create mode 100644 libnm-util/nm-setting-team-port.h At some point here perhaps we should minimally verify the JSON in the team master and team port configs, but that's not necessary ATM. Dan diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am index 495a42d..554b4a4 100644 --- a/libnm-util/Makefile.am +++ b/libnm-util/Makefile.am @@ -19,6 +19,7 @@ libnm_util_include_HEADERS =\ nm-setting-bluetooth.h \ nm-setting-bond.h \ nm-setting-team.h \ + nm-setting-team-port.h \ nm-setting-bridge.h \ nm-setting-bridge-port.h\ nm-setting-connection.h \ @@ -57,6 +58,7 @@ libnm_util_la_csources = \ nm-setting-bluetooth.c \ nm-setting-bond.c \ nm-setting-team.c \ + nm-setting-team-port.c \ nm-setting-bridge.c \ nm-setting-bridge-port.c\ nm-setting-connection.c \ diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index f946fb3..512e5bc 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -19,6 +19,7 @@ global: nm_connection_get_setting_bluetooth; nm_connection_get_setting_bond; nm_connection_get_setting_team; + nm_connection_get_setting_team_port; nm_connection_get_setting_bridge; nm_connection_get_setting_bridge_port; nm_connection_get_setting_by_name; @@ -211,6 +212,10 @@ global: nm_setting_team_get_type; nm_setting_team_new; nm_setting_team_get_config; + nm_setting_team_port_error_quark; + nm_setting_team_port_get_type; + nm_setting_team_port_new; + nm_setting_team_port_get_config; nm_setting_bridge_error_get_type; nm_setting_bridge_error_quark; nm_setting_bridge_get_ageing_time; diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index 631fdae..dac66c4 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -49,6 +49,7 @@ #include nm-setting-olpc-mesh.h #include nm-setting-bond.h #include nm-setting-team.h +#include nm-setting-team-port.h #include nm-setting-bridge.h #include nm-setting-bridge-port.h #include nm-setting-vlan.h @@ -1259,6 +1260,22 @@ nm_connection_get_setting_team (NMConnection *connection) } /** + * nm_connection_get_setting_team_port: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingTeamPort the connection might contain. + * + * Returns: (transfer none): an #NMSettingTeamPort if the connection contains one, otherwise %NULL + **/ +NMSettingTeamPort * +nm_connection_get_setting_team_port (NMConnection *connection) +{ + g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + + return (NMSettingTeamPort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM_PORT); +} + +/** * nm_connection_get_setting_bridge: * @connection: the #NMConnection * diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h index 7897628..f310319 100644 --- a/libnm-util/nm-connection.h +++ b/libnm-util/nm-connection.h @@ -34,6 +34,7 @@ #include nm-setting-bluetooth.h #include nm-setting-bond.h #include nm-setting-team.h +#include nm-setting-team-port.h #include nm-setting-bridge.h #include nm-setting-bridge-port.h #include nm-setting-cdma.h @@ -202,6 +203,7 @@ NMSetting8021x * nm_connection_get_setting_802_1x(NMConnec NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection); NMSettingBond *nm_connection_get_setting_bond (NMConnection *connection); NMSettingTeam *nm_connection_get_setting_team (NMConnection *connection); +NMSettingTeamPort *nm_connection_get_setting_team_port (NMConnection *connection); NMSettingBridge * nm_connection_get_setting_bridge (NMConnection *connection); NMSettingBridgePort * nm_connection_get_setting_bridge_port (NMConnection *connection); NMSettingCdma *nm_connection_get_setting_cdma (NMConnection *connection); diff --git a/libnm-util/nm-setting-team-port.c b/libnm-util/nm-setting-team-port.c new file mode 100644 index 000..0d650ec --- /dev/null +++
Re: [patch NetworkManager v2 6/6] nm-device-team: spawn teamd for team device connection
On Mon, 2013-07-15 at 09:46 +0200, Jiri Pirko wrote: Signed-off-by: Jiri Pirko j...@resnulli.us --- src/devices/nm-device-team.c | 283 ++- 1 file changed, 282 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device-team.c b/src/devices/nm-device-team.c index 320b659..ac0467c 100644 --- a/src/devices/nm-device-team.c +++ b/src/devices/nm-device-team.c @@ -20,8 +20,13 @@ #include config.h +#include sys/types.h +#include unistd.h +#include signal.h +#include sys/wait.h #include glib.h #include glib/gi18n.h +#include gio/gio.h #include netinet/ether.h @@ -34,6 +39,7 @@ #include nm-dbus-glib-types.h #include nm-dbus-manager.h #include nm-enum-types.h +#include nm-posix-signals.h #include nm-device-team-glue.h @@ -45,7 +51,11 @@ G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) #define NM_TEAM_ERROR (nm_team_error_quark ()) typedef struct { - int dummy; + GPid teamd_pid; + guint teamd_process_watch; + guint teamd_timeout; + guint teamd_dbus_watch; + gboolean teamd_on_dbus; } NMDeviceTeamPrivate; enum { @@ -179,9 +189,267 @@ match_l2_config (NMDevice *self, NMConnection *connection) /**/ +typedef struct { + int pid; +} KillInfo; + +static gboolean +ensure_killed (gpointer data) +{ + KillInfo *info = data; + + if (kill (info-pid, 0) == 0) + kill (info-pid, SIGKILL); + + /* ensure the child is reaped */ + nm_log_dbg (LOGD_TEAM, waiting for teamd pid %d to exit, info-pid); + waitpid (info-pid, NULL, 0); + nm_log_dbg (LOGD_TEAM, teamd pid %d cleaned up, info-pid); + + g_free (info); + return FALSE; +} + +static void +service_kill (int pid) +{ + if (kill (pid, SIGTERM) == 0) { + KillInfo *info; + + info = g_malloc0 (sizeof (KillInfo)); + info-pid = pid; You don't actually need the 'info' thing here, since the pid will always be a 32-bit integer (AFAIK?), you can use GINT_TO_POINTER (pid) and skip all the allocation/free stuff. So it would really end up as: static gboolean ensure_killed (gpointer data) { int pid = GPOINTER_TO_INT (data); kill (pid); ... return FALSE; } static void service_kill (...) { if (kill (pid, SIGTERM)) { g_timeout_add_seconds (2, ensure_killed, GINT_TO_POINTER (pid)); } ... } + g_timeout_add_seconds (2, ensure_killed, info); + } + else { + kill (pid, SIGKILL); + + /* ensure the child is reaped */ + nm_log_dbg (LOGD_TEAM, waiting for teamd pid %d to exit, pid); + waitpid (pid, NULL, 0); + nm_log_dbg (LOGD_TEAM, teamd pid %d cleaned up, pid); + } +} + +static void +teamd_timeout_remove (NMDevice *dev) +{ + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + + if (priv-teamd_timeout) { + g_source_remove (priv-teamd_timeout); + priv-teamd_timeout = 0; + } +} + +static void +teamd_cleanup (NMDevice *dev) +{ + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + + if (priv-teamd_dbus_watch) { + g_source_remove (priv-teamd_dbus_watch); + priv-teamd_dbus_watch = 0; + } + + if (priv-teamd_process_watch) { + g_source_remove (priv-teamd_process_watch); + priv-teamd_process_watch = 0; + } + + if (priv-teamd_pid 0) { + service_kill (priv-teamd_pid); + priv-teamd_pid = 0; + } + + teamd_timeout_remove (dev); + + priv-teamd_on_dbus = FALSE; +} + +static gboolean +teamd_timeout_cb (gpointer user_data) +{ + NMDevice *dev = NM_DEVICE (user_data); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + + if (priv-teamd_timeout) { + nm_log_info (LOGD_TEAM, (%s): teamd timed out., nm_device_get_iface (dev)); + teamd_cleanup (dev); + } + + return FALSE; +} + +static void +teamd_dbus_appeared (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data) +{ + NMDevice *dev = NM_DEVICE (user_data); + NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + + if (!priv-teamd_dbus_watch) + return; + + nm_log_info (LOGD_TEAM, (%s): teamd appeared on D-Bus, nm_device_get_iface (dev)); + priv-teamd_on_dbus = FALSE; + teamd_timeout_remove (dev); + nm_device_activate_schedule_stage2_device_config (dev); +} + +static void +teamd_dbus_vanished (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + NMDevice *dev = NM_DEVICE (user_data); +
Re: How frequently org.freedektop.ModemManager.Modem.Cdma.SignalQuality signals signal strength?
$ sudo lsusb -v -d 19d2:fff1 Bus 001 Device 006: ID 19d2:fff1 ZTE WCDMA Technologies MSM Device Descriptor: bLength18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize064 idVendor 0x19d2 ZTE WCDMA Technologies MSM idProduct 0xfff1 bcdDevice0.00 iManufacturer 1 ZTE, Incorporated iProduct2 ZTE CDMA Tech iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 154 bNumInterfaces 6 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 500mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 4 Data Interface Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes3 Transfer TypeInterrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 128 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 4 Data Interface Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x84 EP 4 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x04 EP 4 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber2 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 4 Data Interface Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x87 EP 7 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x07 EP 7 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber3 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor
Re: How frequently org.freedektop.ModemManager.Modem.Cdma.SignalQuality signals signal strength?
Modem's model no. is *AC2738* On Wed, Jul 24, 2013 at 10:18 AM, satya gowtham kudupudi satyagowtha...@gmail.com wrote: $ sudo lsusb -v -d 19d2:fff1 Bus 001 Device 006: ID 19d2:fff1 ZTE WCDMA Technologies MSM Device Descriptor: bLength18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize064 idVendor 0x19d2 ZTE WCDMA Technologies MSM idProduct 0xfff1 bcdDevice0.00 iManufacturer 1 ZTE, Incorporated iProduct2 ZTE CDMA Tech iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 154 bNumInterfaces 6 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 500mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 4 Data Interface Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes3 Transfer TypeInterrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 bytes bInterval 128 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x82 EP 2 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 4 Data Interface Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x84 EP 4 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x04 EP 4 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber2 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass255 Vendor Specific Subclass bInterfaceProtocol255 Vendor Specific Protocol iInterface 4 Data Interface Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x87 EP 7 IN bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x07 EP 7 OUT bmAttributes2 Transfer TypeBulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Interface Descriptor:
Re: [patch NetworkManager v2 2/6] add setting for team port
Wed, Jul 24, 2013 at 01:26:00AM CEST, d...@redhat.com wrote: On Mon, 2013-07-15 at 09:46 +0200, Jiri Pirko wrote: Signed-off-by: Jiri Pirko j...@resnulli.us --- libnm-util/Makefile.am| 2 + libnm-util/libnm-util.ver | 5 ++ libnm-util/nm-connection.c| 17 libnm-util/nm-connection.h| 2 + libnm-util/nm-setting-team-port.c | 174 ++ libnm-util/nm-setting-team-port.h | 76 + 6 files changed, 276 insertions(+) create mode 100644 libnm-util/nm-setting-team-port.c create mode 100644 libnm-util/nm-setting-team-port.h At some point here perhaps we should minimally verify the JSON in the team master and team port configs, but that's not necessary ATM. nod Dan diff --git a/libnm-util/Makefile.am b/libnm-util/Makefile.am index 495a42d..554b4a4 100644 --- a/libnm-util/Makefile.am +++ b/libnm-util/Makefile.am @@ -19,6 +19,7 @@ libnm_util_include_HEADERS = \ nm-setting-bluetooth.h \ nm-setting-bond.h \ nm-setting-team.h \ +nm-setting-team-port.h \ nm-setting-bridge.h \ nm-setting-bridge-port.h\ nm-setting-connection.h \ @@ -57,6 +58,7 @@ libnm_util_la_csources = \ nm-setting-bluetooth.c \ nm-setting-bond.c \ nm-setting-team.c \ +nm-setting-team-port.c \ nm-setting-bridge.c \ nm-setting-bridge-port.c\ nm-setting-connection.c \ diff --git a/libnm-util/libnm-util.ver b/libnm-util/libnm-util.ver index f946fb3..512e5bc 100644 --- a/libnm-util/libnm-util.ver +++ b/libnm-util/libnm-util.ver @@ -19,6 +19,7 @@ global: nm_connection_get_setting_bluetooth; nm_connection_get_setting_bond; nm_connection_get_setting_team; +nm_connection_get_setting_team_port; nm_connection_get_setting_bridge; nm_connection_get_setting_bridge_port; nm_connection_get_setting_by_name; @@ -211,6 +212,10 @@ global: nm_setting_team_get_type; nm_setting_team_new; nm_setting_team_get_config; +nm_setting_team_port_error_quark; +nm_setting_team_port_get_type; +nm_setting_team_port_new; +nm_setting_team_port_get_config; nm_setting_bridge_error_get_type; nm_setting_bridge_error_quark; nm_setting_bridge_get_ageing_time; diff --git a/libnm-util/nm-connection.c b/libnm-util/nm-connection.c index 631fdae..dac66c4 100644 --- a/libnm-util/nm-connection.c +++ b/libnm-util/nm-connection.c @@ -49,6 +49,7 @@ #include nm-setting-olpc-mesh.h #include nm-setting-bond.h #include nm-setting-team.h +#include nm-setting-team-port.h #include nm-setting-bridge.h #include nm-setting-bridge-port.h #include nm-setting-vlan.h @@ -1259,6 +1260,22 @@ nm_connection_get_setting_team (NMConnection *connection) } /** + * nm_connection_get_setting_team_port: + * @connection: the #NMConnection + * + * A shortcut to return any #NMSettingTeamPort the connection might contain. + * + * Returns: (transfer none): an #NMSettingTeamPort if the connection contains one, otherwise %NULL + **/ +NMSettingTeamPort * +nm_connection_get_setting_team_port (NMConnection *connection) +{ +g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); + +return (NMSettingTeamPort *) nm_connection_get_setting (connection, NM_TYPE_SETTING_TEAM_PORT); +} + +/** * nm_connection_get_setting_bridge: * @connection: the #NMConnection * diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h index 7897628..f310319 100644 --- a/libnm-util/nm-connection.h +++ b/libnm-util/nm-connection.h @@ -34,6 +34,7 @@ #include nm-setting-bluetooth.h #include nm-setting-bond.h #include nm-setting-team.h +#include nm-setting-team-port.h #include nm-setting-bridge.h #include nm-setting-bridge-port.h #include nm-setting-cdma.h @@ -202,6 +203,7 @@ NMSetting8021x * nm_connection_get_setting_802_1x(NMConnec NMSettingBluetooth * nm_connection_get_setting_bluetooth (NMConnection *connection); NMSettingBond *nm_connection_get_setting_bond (NMConnection *connection); NMSettingTeam *nm_connection_get_setting_team (NMConnection *connection); +NMSettingTeamPort *nm_connection_get_setting_team_port (NMConnection *connection); NMSettingBridge * nm_connection_get_setting_bridge (NMConnection *connection); NMSettingBridgePort * nm_connection_get_setting_bridge_port (NMConnection *connection); NMSettingCdma *nm_connection_get_setting_cdma (NMConnection *connection); diff --git a/libnm-util/nm-setting-team-port.c b/libnm-util/nm-setting-team-port.c new file mode 100644 index 000..0d650ec --- /dev/null
Re: [patch NetworkManager v2 6/6] nm-device-team: spawn teamd for team device connection
Wed, Jul 24, 2013 at 01:53:56AM CEST, d...@redhat.com wrote: On Mon, 2013-07-15 at 09:46 +0200, Jiri Pirko wrote: Signed-off-by: Jiri Pirko j...@resnulli.us --- src/devices/nm-device-team.c | 283 ++- 1 file changed, 282 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device-team.c b/src/devices/nm-device-team.c index 320b659..ac0467c 100644 --- a/src/devices/nm-device-team.c +++ b/src/devices/nm-device-team.c @@ -20,8 +20,13 @@ #include config.h +#include sys/types.h +#include unistd.h +#include signal.h +#include sys/wait.h #include glib.h #include glib/gi18n.h +#include gio/gio.h #include netinet/ether.h @@ -34,6 +39,7 @@ #include nm-dbus-glib-types.h #include nm-dbus-manager.h #include nm-enum-types.h +#include nm-posix-signals.h #include nm-device-team-glue.h @@ -45,7 +51,11 @@ G_DEFINE_TYPE (NMDeviceTeam, nm_device_team, NM_TYPE_DEVICE) #define NM_TEAM_ERROR (nm_team_error_quark ()) typedef struct { -int dummy; +GPid teamd_pid; +guint teamd_process_watch; +guint teamd_timeout; +guint teamd_dbus_watch; +gboolean teamd_on_dbus; } NMDeviceTeamPrivate; enum { @@ -179,9 +189,267 @@ match_l2_config (NMDevice *self, NMConnection *connection) /**/ +typedef struct { +int pid; +} KillInfo; + +static gboolean +ensure_killed (gpointer data) +{ +KillInfo *info = data; + +if (kill (info-pid, 0) == 0) +kill (info-pid, SIGKILL); + +/* ensure the child is reaped */ +nm_log_dbg (LOGD_TEAM, waiting for teamd pid %d to exit, info-pid); +waitpid (info-pid, NULL, 0); +nm_log_dbg (LOGD_TEAM, teamd pid %d cleaned up, info-pid); + +g_free (info); +return FALSE; +} + +static void +service_kill (int pid) +{ +if (kill (pid, SIGTERM) == 0) { +KillInfo *info; + +info = g_malloc0 (sizeof (KillInfo)); +info-pid = pid; You don't actually need the 'info' thing here, since the pid will always be a 32-bit integer (AFAIK?), you can use GINT_TO_POINTER (pid) and skip all the allocation/free stuff. So it would really end up as: static gboolean ensure_killed (gpointer data) { int pid = GPOINTER_TO_INT (data); kill (pid); ... return FALSE; } static void service_kill (...) { if (kill (pid, SIGTERM)) { g_timeout_add_seconds (2, ensure_killed, GINT_TO_POINTER (pid)); } ... } You are right that structure is not needed per say. But even with int, I would have to do malloc/free anyway (because ensure_killed() is called when original pid variable is not available anymore) I always like to wrap this in struct, seems nicer to me. +g_timeout_add_seconds (2, ensure_killed, info); +} +else { +kill (pid, SIGKILL); + +/* ensure the child is reaped */ +nm_log_dbg (LOGD_TEAM, waiting for teamd pid %d to exit, pid); +waitpid (pid, NULL, 0); +nm_log_dbg (LOGD_TEAM, teamd pid %d cleaned up, pid); +} +} + +static void +teamd_timeout_remove (NMDevice *dev) +{ +NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + +if (priv-teamd_timeout) { +g_source_remove (priv-teamd_timeout); +priv-teamd_timeout = 0; +} +} + +static void +teamd_cleanup (NMDevice *dev) +{ +NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + +if (priv-teamd_dbus_watch) { +g_source_remove (priv-teamd_dbus_watch); +priv-teamd_dbus_watch = 0; +} + +if (priv-teamd_process_watch) { +g_source_remove (priv-teamd_process_watch); +priv-teamd_process_watch = 0; +} + +if (priv-teamd_pid 0) { +service_kill (priv-teamd_pid); +priv-teamd_pid = 0; +} + +teamd_timeout_remove (dev); + +priv-teamd_on_dbus = FALSE; +} + +static gboolean +teamd_timeout_cb (gpointer user_data) +{ +NMDevice *dev = NM_DEVICE (user_data); +NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + +if (priv-teamd_timeout) { +nm_log_info (LOGD_TEAM, (%s): teamd timed out., nm_device_get_iface (dev)); +teamd_cleanup (dev); +} + +return FALSE; +} + +static void +teamd_dbus_appeared (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data) +{ +NMDevice *dev = NM_DEVICE (user_data); +NMDeviceTeamPrivate *priv = NM_DEVICE_TEAM_GET_PRIVATE (dev); + +if (!priv-teamd_dbus_watch) +return; + +nm_log_info (LOGD_TEAM, (%s): teamd appeared on D-Bus, nm_device_get_iface (dev)); +priv-teamd_on_dbus = FALSE; +teamd_timeout_remove (dev); +