loopback-setup.c revision e95e909d820429ba34fa6f6f1b0109ac22743b47
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen This file is part of systemd.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Copyright 2010 Lennart Poettering
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen systemd is free software; you can redistribute it and/or modify it
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen under the terms of the GNU Lesser General Public License as published by
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen the Free Software Foundation; either version 2.1 of the License, or
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen (at your option) any later version.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen systemd is distributed in the hope that it will be useful, but
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen WITHOUT ANY WARRANTY; without even the implied warranty of
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen Lesser General Public License for more details.
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen You should have received a copy of the GNU Lesser General Public License
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen along with systemd; If not, see <http://www.gnu.org/licenses/>.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering/* this is hardcoded in the kernel, so don't look it up */
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringstatic int start_loopback(sd_rtnl *rtnl) {
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering _cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL;
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen r = sd_rtnl_message_new_link(rtnl, &req, RTM_SETLINK, LOOPBACK_IFINDEX);
a501033335ed402c8f7e86fe41a15531ba69abd7Tom Gundersen r = sd_rtnl_message_link_set_flags(req, IFF_UP, IFF_UP);
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmekstatic bool check_loopback(sd_rtnl *rtnl) {
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek _cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL, *reply = NULL;
2ad8416dd057e7e3185169609ca3006e7649f576Zbigniew Jędrzejewski-Szmek r = sd_rtnl_message_new_link(rtnl, &req, RTM_GETLINK, LOOPBACK_IFINDEX);
43d60b77a83b3185e37c65c4f2649d24c227c7f0Tom Gundersen r = sd_rtnl_message_link_get_flags(reply, &flags);
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen return log_warning_errno(EPERM, "Failed to configure loopback device: %m");
9a4b012e43f23516373bf398dd9a458439d19939Tom Gundersen } else if (r < 0)
af6f0d422c521374ee6a2dd92df5935a5a476ae5Tom Gundersen return log_warning_errno(r, "Failed to configure loopback device: %m");