From 199c9dfa9b4cdb32de9edb82aa672dbcd81eadd69db3a16a6db045ba7765d247 Mon Sep 17 00:00:00 2001 From: Nirmoy Das Date: Wed, 22 Nov 2017 10:50:23 +0000 Subject: [PATCH] Accepting request 544370 from home:ndas:branches:network - sync with SLES changes(bsc#1055708) * Add check_if_psr_ops_were_initialized.patch: ** Fix teamd segfault when link_watch initialization callbacks fail (e.g. lw_psr_port_added() in case of activebackup runner) due to an attempt to change hwaddr on an enslaved, link up port device. Note: enslavement triggers initialization callbacks. * Add ignore_ebusy_for_team_hwaddr_set.patch: ** Make PortAdd and PortRemove dbus methods work for all runners. Ignore attempts to change hwaddr of an already enslaved devices. (fate#318389,fate#317728,fate#316923) - Add start_teamd_from_usr_sbin.patch: * Modify service file to start teamd instance from /usr/sbin. OBS-URL: https://build.opensuse.org/request/show/544370 OBS-URL: https://build.opensuse.org/package/show/network/libteam?expand=0&rev=9 --- check_if_psr_ops_were_initialized.patch | 44 +++++++++++++++++++++++++ ignore_ebusy_for_team_hwaddr_set.patch | 14 ++++++++ libteam.changes | 16 +++++++++ libteam.spec | 38 ++++++++++++++++++++- start_teamd_from_usr_sbin.patch | 12 +++++++ 5 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 check_if_psr_ops_were_initialized.patch create mode 100644 ignore_ebusy_for_team_hwaddr_set.patch create mode 100644 start_teamd_from_usr_sbin.patch diff --git a/check_if_psr_ops_were_initialized.patch b/check_if_psr_ops_were_initialized.patch new file mode 100644 index 0000000..68951bc --- /dev/null +++ b/check_if_psr_ops_were_initialized.patch @@ -0,0 +1,44 @@ +Index: libteam-1.16/teamd/teamd_lw_psr.c +=================================================================== +--- libteam-1.16.orig/teamd/teamd_lw_psr.c ++++ libteam-1.16/teamd/teamd_lw_psr.c +@@ -39,6 +39,9 @@ static int lw_psr_callback_periodic(stru + bool link_up = common_ppriv->link_up; + int err; + ++ if (!psr_ppriv->ops) ++ return -EINVAL; ++ + if (psr_ppriv->reply_received) { + link_up = true; + psr_ppriv->missed = 0; +@@ -65,6 +68,9 @@ static int lw_psr_callback_socket(struct + { + struct lw_psr_port_priv *psr_ppriv = priv; + ++ if (!psr_ppriv->ops) ++ return -EINVAL; ++ + return psr_ppriv->ops->receive(psr_ppriv); + } + +@@ -120,6 +126,9 @@ int lw_psr_port_added(struct teamd_conte + struct lw_psr_port_priv *psr_ppriv = priv; + int err; + ++ if (!psr_ppriv->ops) ++ return -EINVAL; ++ + err = lw_psr_load_options(ctx, tdport, psr_ppriv); + if (err) { + teamd_log_err("Failed to load options."); +@@ -182,6 +191,9 @@ void lw_psr_port_removed(struct teamd_co + { + struct lw_psr_port_priv *psr_ppriv = priv; + ++ if (!psr_ppriv->ops) ++ return; ++ + teamd_loop_callback_del(ctx, LW_PERIODIC_CB_NAME, psr_ppriv); + teamd_loop_callback_del(ctx, LW_SOCKET_CB_NAME, psr_ppriv); + psr_ppriv->ops->sock_close(psr_ppriv); diff --git a/ignore_ebusy_for_team_hwaddr_set.patch b/ignore_ebusy_for_team_hwaddr_set.patch new file mode 100644 index 0000000..ca15b9d --- /dev/null +++ b/ignore_ebusy_for_team_hwaddr_set.patch @@ -0,0 +1,14 @@ +Index: libteam-1.18/libteam/libteam.c +=================================================================== +--- libteam-1.18.orig/libteam/libteam.c ++++ libteam-1.18/libteam/libteam.c +@@ -1633,6 +1633,9 @@ int team_hwaddr_set(struct team_handle * + err = rtnl_link_change(th->nl_cli.sock, link, link, 0); + err = -nl2syserr(err); + ++ if (err == -EBUSY) ++ err = 0; ++ + nl_addr_put(nl_addr); + + errout: diff --git a/libteam.changes b/libteam.changes index acd9e7e..fc048f8 100644 --- a/libteam.changes +++ b/libteam.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Wed Nov 22 11:26:44 CET 2017 - ndas@suse.de + +- sync with SLES changes(bsc#1055708) +* Add check_if_psr_ops_were_initialized.patch: +** Fix teamd segfault when link_watch initialization callbacks fail + (e.g. lw_psr_port_added() in case of activebackup runner) due to + an attempt to change hwaddr on an enslaved, link up port device. + Note: enslavement triggers initialization callbacks. +* Add ignore_ebusy_for_team_hwaddr_set.patch: +** Make PortAdd and PortRemove dbus methods work for all runners. + Ignore attempts to change hwaddr of an already enslaved devices. + (fate#318389,fate#317728,fate#316923) +- Add start_teamd_from_usr_sbin.patch: +* Modify service file to start teamd instance from /usr/sbin. + ------------------------------------------------------------------- Mon Nov 21 00:59:27 UTC 2016 - jengelh@inai.de diff --git a/libteam.spec b/libteam.spec index c4a2c4d..1785a8c 100644 --- a/libteam.spec +++ b/libteam.spec @@ -39,9 +39,21 @@ BuildRequires: pkgconfig(libnl-3.0) >= 3.2.0 BuildRequires: pkgconfig(libnl-cli-3.0) >= 3.2.0 BuildRequires: pkgconfig(libnl-genl-3.0) >= 3.2.0 BuildRequires: pkgconfig(libnl-route-3.0) >= 3.2.0 +BuildRequires: libcap-devel %if 0%{?suse_version} >= 1220 BuildRequires: systemd-rpm-macros %endif +Patch0: check_if_psr_ops_were_initialized.patch +Patch1: start_teamd_from_usr_sbin.patch +Patch2: ignore_ebusy_for_team_hwaddr_set.patch + +# Some defines +# +%define teamd_user teamd +%define teamd_group daemon +%define teamd_daemon_directory /run/teamd +%define teamd_dbus_policy_directory %_sysconfdir/dbus-1/system.d +%define teamd_dbus_policy_name org.libteam.teamd.conf %description A library which is the user-space counterpart for the team network @@ -109,10 +121,16 @@ programs that will manipulate team network devices. %prep %setup -q +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 %build %configure --includedir="%_includedir/pkg/%name" --bindir="%_sbindir" \ - --disable-static + --disable-static \ + --with-run-dir=%teamd_daemon_directory \ + --with-user=%teamd_user \ + --with-group=%teamd_group # Use CFLAGS= to kill -Werror make %{?_smp_mflags} CFLAGS="%optflags" @@ -133,15 +151,26 @@ mkdir -p "$b/%_unitdir"; install -pm0644 teamd/redhat/systemd/*.service "$b/%_unitdir/"; %endif +%if 0%{?_sysconfdir:1} +mkdir -p "$b/%teamd_dbus_policy_directory/"; +install -pm0644 teamd/dbus/teamd.conf "$b/%teamd_dbus_policy_directory/%teamd_dbus_policy_name"; +%endif + %check make check %pre tools +%{_sbindir}/groupadd -r %teamd_group 2> /dev/null || : +%{_sbindir}/useradd -r -g %teamd_group -s /bin/false -c "Teamd daemon user" -d %{_localstatedir}/lib/empty %teamd_user 2> /dev/null || : +%{_sbindir}/usermod -g %teamd_group %teamd_user 2>/dev/null || : +test -L %teamd_daemon_directory || rm -rf %teamd_daemon_directory && : %if 0%{?_unitdir:1} %service_add_pre teamd@.service %endif %post tools +# reload dbus to apply new teamd's policy +/usr/bin/systemctl reload dbus.service 2>/dev/null || : %if 0%{?_unitdir:1} %service_add_post teamd@.service %endif @@ -155,6 +184,10 @@ make check %if 0%{?_unitdir:1} %service_del_postun teamd@.service %endif +# reload dbus to forget teamd's policy +if [ ${FIRST_ARG:-$1} -eq 0 ]; then + /usr/bin/systemctl reload dbus.service 2>/dev/null || : +fi %post -n libteam5 -p /sbin/ldconfig %postun -n libteam5 -p /sbin/ldconfig @@ -180,6 +213,9 @@ make check %defattr(-,root,root) %_sbindir/bond2team %_sbindir/team* +%dir %_sysconfdir/dbus-1 +%dir %teamd_dbus_policy_directory +%config %teamd_dbus_policy_directory/%teamd_dbus_policy_name %_mandir/man1/* %_mandir/man5/* %_mandir/man8/* diff --git a/start_teamd_from_usr_sbin.patch b/start_teamd_from_usr_sbin.patch new file mode 100644 index 0000000..7227726 --- /dev/null +++ b/start_teamd_from_usr_sbin.patch @@ -0,0 +1,12 @@ +Index: libteam-1.16/teamd/redhat/systemd/teamd@.service +=================================================================== +--- libteam-1.16.orig/teamd/redhat/systemd/teamd@.service ++++ libteam-1.16/teamd/redhat/systemd/teamd@.service +@@ -3,6 +3,6 @@ Description=Team Daemon for device %I + + [Service] + BusName=org.libteam.teamd.%i +-ExecStart=/usr/bin/teamd -U -D -o -t %i -f /run/teamd/%i.conf ++ExecStart=/usr/sbin/teamd -U -D -o -t %i -f /run/teamd/%i.conf + Restart=on-failure + RestartPreventExitStatus=1