Skip to content

Commit 5ce076c

Browse files
rmetrichvathpela
authored andcommitted
Implement --uri option for use with --ifname
New --uri option enables to specify a URI when creating a network boot entry, e.g. # efibootmgr -L NetBoot -i enp7s0 --uri http://foobar/grubx64.efi This requires support in libefiboot, which is provided by version 39 of efivar. Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
1 parent 4a8d9c6 commit 5ce076c

4 files changed

Lines changed: 35 additions & 24 deletions

File tree

efibootmgr.spec.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Group: System Environment/Base
66
License: GPLv2+
77
URL: https://github.com/rhboot/%{name}/
88
BuildRequires: git, popt-devel
9-
BuildRequires: efivar-libs >= 30-1, efivar-devel >= 30-1
9+
BuildRequires: efivar-libs >= 39-1, efivar-devel >= 39-1
1010
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXXXX)
1111
# EFI/UEFI don't exist on PPC
1212
ExclusiveArch: %{ix86} x86_64 aarch64 arm

src/efi.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -174,37 +174,40 @@ make_linux_load_option(uint8_t **data, size_t *data_size,
174174
efidp dp = NULL;
175175

176176
if (opts.iface && opts.ip_version == EFIBOOTMGR_IPV4) {
177-
needed = efi_generate_ipv4_device_path(NULL, 0, opts.iface,
178-
opts.local_ip_addr,
179-
opts.remote_ip_addr,
180-
opts.gateway_ip_addr,
181-
opts.ip_netmask,
182-
opts.ip_local_port,
183-
opts.ip_remote_port,
184-
opts.ip_protocol,
185-
opts.ip_addr_origin);
177+
needed = efi_generate_ipv4_device_path_with_uri(
178+
NULL, 0, opts.iface,
179+
opts.local_ip_addr,
180+
opts.remote_ip_addr,
181+
opts.gateway_ip_addr,
182+
opts.ip_netmask,
183+
opts.ip_local_port,
184+
opts.ip_remote_port,
185+
opts.ip_protocol,
186+
opts.ip_addr_origin,
187+
opts.uri);
186188
if (needed < 0) {
187-
efi_error("efi_generate_ipv4_device_path() = %zd (failed)",
189+
efi_error("efi_generate_ipv4_device_path_with_uri() = %zd (failed)",
188190
needed);
189191
return -1;
190192
}
191193
if (data_size && *data_size) {
192194
dp = malloc(needed);
193195

194-
needed = efi_generate_ipv4_device_path(
195-
(uint8_t *)dp, needed,
196-
opts.iface,
197-
opts.local_ip_addr,
198-
opts.remote_ip_addr,
199-
opts.gateway_ip_addr,
200-
opts.ip_netmask,
201-
opts.ip_local_port,
202-
opts.ip_remote_port,
203-
opts.ip_protocol,
204-
opts.ip_addr_origin);
196+
needed = efi_generate_ipv4_device_path_with_uri(
197+
(uint8_t *)dp, needed,
198+
opts.iface,
199+
opts.local_ip_addr,
200+
opts.remote_ip_addr,
201+
opts.gateway_ip_addr,
202+
opts.ip_netmask,
203+
opts.ip_local_port,
204+
opts.ip_remote_port,
205+
opts.ip_protocol,
206+
opts.ip_addr_origin,
207+
opts.uri);
205208
if (needed < 0) {
206209
free(dp);
207-
efi_error("efi_generate_ipv4_device_path() = %zd (failed)",
210+
efi_error("efi_generate_ipv4_device_path_with_uri() = %zd (failed)",
208211
needed);
209212
return -1;
210213
}

src/efibootmgr.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,8 +1410,9 @@ usage()
14101410
printf("\t-f | --reconnect Re-connect devices after driver is loaded.\n");
14111411
printf("\t-F | --no-reconnect Do not re-connect devices after driver is loaded.\n");
14121412
printf("\t-g | --gpt Force disk with invalid PMBR to be treated as GPT.\n");
1413-
printf("\t-i | --iface name Create a netboot entry for the named interface.\n");
1413+
printf("\t-i | --iface name Create a netboot entry for the named interface (IPv4+DHCP support only).\n");
14141414
printf("\t-I | --index number When creating an entry, insert it in bootorder at specified position (default: 0).\n");
1415+
printf("\t --uri Uri Specify an Uri (for use with --iface option).\n");
14151416
printf("\t-l | --loader name (Defaults to \""DEFAULT_LOADER"\").\n");
14161417
printf("\t-L | --label label Boot manager display label (defaults to \"Linux\").\n");
14171418
printf("\t-m | --mirror-below-4G t|f Mirror memory below 4GB.\n");
@@ -1483,6 +1484,7 @@ parse_opts(int argc, char **argv)
14831484
{"gpt", no_argument, 0, 'g'},
14841485
{"iface", required_argument, 0, 'i'},
14851486
{"index", required_argument, 0, 'I'},
1487+
{"uri", required_argument, 0, 0},
14861488
{"keep", no_argument, 0, 'k'},
14871489
{"loader", required_argument, 0, 'l'},
14881490
{"label", required_argument, 0, 'L'},
@@ -1771,6 +1773,8 @@ parse_opts(int argc, char **argv)
17711773
opts.abbreviate_path != EFIBOOTMGR_PATH_ABBREV_FILE)
17721774
errx(41, "contradicting --full-dev-path/--file-dev-path/-e options");
17731775
opts.abbreviate_path = EFIBOOTMGR_PATH_ABBREV_FILE;
1776+
} else if (!strcmp(long_options[option_index].name, "uri")) {
1777+
opts.uri = optarg;
17741778
} else {
17751779
usage();
17761780
exit(1);
@@ -1813,6 +1817,9 @@ main(int argc, char **argv)
18131817

18141818
verbose = opts.verbose;
18151819

1820+
if (opts.uri && !opts.iface)
1821+
errx(25, "--uri is supported only with --iface option.");
1822+
18161823
if (opts.sysprep && opts.driver)
18171824
errx(25, "--sysprep and --driver may not be used together.");
18181825

src/include/efibootmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef struct {
5959
uint16_t ip_remote_port;
6060
uint16_t ip_protocol;
6161
uint8_t ip_addr_origin;
62+
char *uri;
6263

6364
char *loader;
6465
unsigned char *label;

0 commit comments

Comments
 (0)