]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd/sd-netlink/local-addresses.c
tree-wide: beautify remaining copyright statements
[thirdparty/systemd.git] / src / libsystemd / sd-netlink / local-addresses.c
index 23acec4061a04fc98804e587f53f11b47551a085..f7483912f1d6311b1a1ab67032284fa7689490d8 100644 (file)
@@ -1,22 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 /***
-  This file is part of systemd.
-
-  Copyright 2008-2011 Lennart Poettering
-  Copyright 2014 Tom Gundersen
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+  Copyright © 2014 Tom Gundersen
 ***/
 
 #include "sd-netlink.h"
@@ -158,8 +142,7 @@ int local_addresses(sd_netlink *context, int ifindex, int af, struct local_addre
 
         qsort_safe(list, n_list, sizeof(struct local_address), address_compare);
 
-        *ret = list;
-        list = NULL;
+        *ret = TAKE_PTR(list);
 
         return (int) n_list;
 }
@@ -225,6 +208,8 @@ int local_gateways(sd_netlink *context, int ifindex, int af, struct local_addres
                         continue;
 
                 r = sd_netlink_message_read_u32(m, RTA_OIF, &ifi);
+                if (r == -ENODATA) /* Not all routes have an RTA_OIF attribute (for example nexthop ones) */
+                        continue;
                 if (r < 0)
                         return r;
                 if (ifindex > 0 && (int) ifi != ifindex)
@@ -269,8 +254,7 @@ int local_gateways(sd_netlink *context, int ifindex, int af, struct local_addres
         if (n_list > 0)
                 qsort(list, n_list, sizeof(struct local_address), address_compare);
 
-        *ret = list;
-        list = NULL;
+        *ret = TAKE_PTR(list);
 
         return (int) n_list;
 }