From 6870b41563771415e305b549de6dfde22a13ea83 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Wed, 29 Jul 2015 22:04:28 +0530 Subject: networkd: fix size of networkd binary This patch fixes the size of networkd Bug #775 before: size systemd-networkd text data bss dec hex filename 1493755 8424392 2337 9920484 975fe4 systemd-networkd After $ size systemd-networkd text data bss dec hex filename 1493555 35752 2337 1531644 175efc systemd-networkd --- src/network/networkd-netdev-tunnel.c | 12 ++---------- src/network/networkd-netdev-tunnel.h | 5 +---- 2 files changed, 3 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/network/networkd-netdev-tunnel.c b/src/network/networkd-netdev-tunnel.c index 7fd9ef584b..265e67b7e3 100644 --- a/src/network/networkd-netdev-tunnel.c +++ b/src/network/networkd-netdev-tunnel.c @@ -404,12 +404,6 @@ int config_parse_tunnel_address(const char *unit, return 0; } -static const char* const ipv6_flowlabel_table[_NETDEV_IPV6_FLOWLABEL_MAX] = { - [NETDEV_IPV6_FLOWLABEL_INHERIT] = "inherit", -}; - -DEFINE_STRING_TABLE_LOOKUP(ipv6_flowlabel, IPv6FlowLabel); - int config_parse_ipv6_flowlabel(const char* unit, const char *filename, unsigned line, @@ -422,7 +416,6 @@ int config_parse_ipv6_flowlabel(const char* unit, void *userdata) { IPv6FlowLabel *ipv6_flowlabel = data; Tunnel *t = userdata; - IPv6FlowLabel s; int k = 0; int r; @@ -431,12 +424,11 @@ int config_parse_ipv6_flowlabel(const char* unit, assert(rvalue); assert(ipv6_flowlabel); - s = ipv6_flowlabel_from_string(rvalue); - if (s != _NETDEV_IPV6_FLOWLABEL_INVALID) { + if (streq(rvalue, "inherit")) { *ipv6_flowlabel = IP6_FLOWINFO_FLOWLABEL; t->flags |= IP6_TNL_F_USE_ORIG_FLOWLABEL; } else { - r = config_parse_unsigned(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &k, userdata); + r = config_parse_int(unit, filename, line, section, section_line, lvalue, ltype, rvalue, &k, userdata); if (r >= 0) { if (k > 0xFFFFF) log_syntax(unit, LOG_ERR, filename, line, k, "Failed to parse IPv6 flowlabel option, ignoring: %s", rvalue); diff --git a/src/network/networkd-netdev-tunnel.h b/src/network/networkd-netdev-tunnel.h index 1fd2b94ae1..e4fa74aef4 100644 --- a/src/network/networkd-netdev-tunnel.h +++ b/src/network/networkd-netdev-tunnel.h @@ -45,6 +45,7 @@ struct Tunnel { uint8_t encap_limit; int family; + int ipv6_flowlabel; unsigned ttl; unsigned tos; @@ -54,7 +55,6 @@ struct Tunnel { union in_addr_union remote; Ip6TnlMode ip6tnl_mode; - IPv6FlowLabel ipv6_flowlabel; bool pmtudisc; bool copy_dscp; @@ -90,9 +90,6 @@ int config_parse_tunnel_address(const char *unit, void *data, void *userdata); -const char *ipv6_flowlabel_to_string(IPv6FlowLabel d) _const_; -IPv6FlowLabel ipv6_flowlabel_from_string(const char *d) _pure_; - int config_parse_ipv6_flowlabel(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, -- cgit v1.2.3-54-g00ecf From 8110e144ff5c3a95a2ac82691ee11528b4e6642a Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Wed, 29 Jul 2015 19:26:49 +0200 Subject: sd-boot: stub - export LoaderDevicePartUUID --- Makefile.am | 6 +++++- src/boot/efi/boot.c | 28 ++++------------------------ src/boot/efi/disk.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/boot/efi/disk.h | 21 +++++++++++++++++++++ src/boot/efi/stub.c | 6 ++++++ 5 files changed, 87 insertions(+), 25 deletions(-) create mode 100644 src/boot/efi/disk.c create mode 100644 src/boot/efi/disk.h (limited to 'src') diff --git a/Makefile.am b/Makefile.am index e908ca2984..4953d8d782 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2519,13 +2519,15 @@ systemd_boot_headers = \ src/boot/efi/util.h \ src/boot/efi/console.h \ src/boot/efi/graphics.h \ - src/boot/efi/pefile.h + src/boot/efi/pefile.h \ + src/boot/efi/disk.h systemd_boot_sources = \ src/boot/efi/util.c \ src/boot/efi/console.c \ src/boot/efi/graphics.c \ src/boot/efi/pefile.c \ + src/boot/efi/disk.c \ src/boot/efi/boot.c EXTRA_DIST += $(systemd_boot_sources) $(systemd_boot_headers) @@ -2558,6 +2560,7 @@ endif stub_headers = \ src/boot/efi/util.h \ src/boot/efi/pefile.h \ + src/boot/efi/disk.h \ src/boot/efi/graphics.h \ src/boot/efi/splash.h \ src/boot/efi/linux.h @@ -2565,6 +2568,7 @@ stub_headers = \ stub_sources = \ src/boot/efi/util.c \ src/boot/efi/pefile.c \ + src/boot/efi/disk.c \ src/boot/efi/graphics.c \ src/boot/efi/splash.c \ src/boot/efi/linux.c \ diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index e8cd8abd26..dde0c41744 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -22,6 +22,7 @@ #include "console.h" #include "graphics.h" #include "pefile.h" +#include "disk.h" #include "linux.h" #ifndef EFI_OS_INDICATIONS_BOOT_TO_FW_UI @@ -1696,11 +1697,11 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { EFI_LOADED_IMAGE *loaded_image; EFI_FILE *root_dir; CHAR16 *loaded_image_path; - EFI_DEVICE_PATH *device_path; EFI_STATUS err; Config config; UINT64 init_usec; BOOLEAN menu = FALSE; + CHAR16 uuid[37]; InitializeLib(image, sys_table); init_usec = time_usec(); @@ -1722,29 +1723,8 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { } /* export the device path this image is started from */ - device_path = DevicePathFromHandle(loaded_image->DeviceHandle); - if (device_path) { - EFI_DEVICE_PATH *path, *paths; - - paths = UnpackDevicePath(device_path); - for (path = paths; !IsDevicePathEnd(path); path = NextDevicePathNode(path)) { - HARDDRIVE_DEVICE_PATH *drive; - CHAR16 uuid[37]; - - if (DevicePathType(path) != MEDIA_DEVICE_PATH) - continue; - if (DevicePathSubType(path) != MEDIA_HARDDRIVE_DP) - continue; - drive = (HARDDRIVE_DEVICE_PATH *)path; - if (drive->SignatureType != SIGNATURE_TYPE_GUID) - continue; - - GuidToString(uuid, (EFI_GUID *)&drive->Signature); - efivar_set(L"LoaderDevicePartUUID", uuid, FALSE); - break; - } - FreePool(paths); - } + if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS) + efivar_set(L"LoaderDevicePartUUID", uuid, FALSE); root_dir = LibOpenRoot(loaded_image->DeviceHandle); if (!root_dir) { diff --git a/src/boot/efi/disk.c b/src/boot/efi/disk.c new file mode 100644 index 0000000000..96063fbc28 --- /dev/null +++ b/src/boot/efi/disk.c @@ -0,0 +1,51 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/* + * This program 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. + * + * This program 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. + * + * Copyright (C) 2015 Kay Sievers + */ + +#include +#include + +#include "util.h" + +EFI_STATUS disk_get_part_uuid(EFI_HANDLE *handle, CHAR16 uuid[37]) { + EFI_DEVICE_PATH *device_path; + EFI_STATUS r = EFI_NOT_FOUND; + + /* export the device path this image is started from */ + device_path = DevicePathFromHandle(handle); + if (device_path) { + EFI_DEVICE_PATH *path, *paths; + + paths = UnpackDevicePath(device_path); + for (path = paths; !IsDevicePathEnd(path); path = NextDevicePathNode(path)) { + HARDDRIVE_DEVICE_PATH *drive; + + if (DevicePathType(path) != MEDIA_DEVICE_PATH) + continue; + if (DevicePathSubType(path) != MEDIA_HARDDRIVE_DP) + continue; + drive = (HARDDRIVE_DEVICE_PATH *)path; + if (drive->SignatureType != SIGNATURE_TYPE_GUID) + continue; + + GuidToString(uuid, (EFI_GUID *)&drive->Signature); + r = EFI_SUCCESS; + break; + } + FreePool(paths); + } + + return r; +} diff --git a/src/boot/efi/disk.h b/src/boot/efi/disk.h new file mode 100644 index 0000000000..1b25343a00 --- /dev/null +++ b/src/boot/efi/disk.h @@ -0,0 +1,21 @@ +/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ + +/* + * This program 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. + * + * This program 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. + * + * Copyright (C) 2015 Kay Sievers + */ + +#ifndef __SDBOOT_DISK_H +#define __SDBOOT_DISK_H + +EFI_STATUS disk_get_part_uuid(EFI_HANDLE *handle, CHAR16 uuid[37]); +#endif diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c index 0b1bc491ed..0c5ee4e9ff 100644 --- a/src/boot/efi/stub.c +++ b/src/boot/efi/stub.c @@ -18,6 +18,7 @@ #include "util.h" #include "pefile.h" +#include "disk.h" #include "graphics.h" #include "splash.h" #include "linux.h" @@ -46,6 +47,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { UINTN szs[ELEMENTSOF(sections)-1] = {}; CHAR8 *cmdline = NULL; UINTN cmdline_len; + CHAR16 uuid[37]; EFI_STATUS err; InitializeLib(image, sys_table); @@ -99,6 +101,10 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) { cmdline = line; } + /* export the device path this image is started from */ + if (disk_get_part_uuid(loaded_image->DeviceHandle, uuid) == EFI_SUCCESS) + efivar_set(L"LoaderDevicePartUUID", uuid, FALSE); + if (szs[3] > 0) graphics_splash((UINT8 *)((UINTN)loaded_image->ImageBase + addrs[3]), szs[3], NULL); -- cgit v1.2.3-54-g00ecf