summaryrefslogtreecommitdiffstats
path: root/term-utils
diff options
context:
space:
mode:
authorStanislav Brabec2018-10-10 19:26:27 +0200
committerKarel Zak2018-10-11 12:09:25 +0200
commit36c55a89871d836a9c6a2832151f0ca907e83ea0 (patch)
treef15b25b62acaeda673e379d8a0ca74ed746302a4 /term-utils
parentagetty: rename variable changed to triggered (diff)
downloadkernel-qcow2-util-linux-36c55a89871d836a9c6a2832151f0ca907e83ea0.tar.gz
kernel-qcow2-util-linux-36c55a89871d836a9c6a2832151f0ca907e83ea0.tar.xz
kernel-qcow2-util-linux-36c55a89871d836a9c6a2832151f0ca907e83ea0.zip
agetty: Watch only protocol requested by issue escapes
To decrease number of reloads, watch only protocol requested by \4 and \6 escapes in issue file. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Diffstat (limited to 'term-utils')
-rw-r--r--term-utils/agetty.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/term-utils/agetty.c b/term-utils/agetty.c
index a0401dfae..137add465 100644
--- a/term-utils/agetty.c
+++ b/term-utils/agetty.c
@@ -153,6 +153,7 @@
# define AGETTY_RELOAD_FDNONE -2 /* uninitialized fd */
static int inotify_fd = AGETTY_RELOAD_FDNONE;
static int netlink_fd = AGETTY_RELOAD_FDNONE;
+static __u32 netlink_groups;
#endif
/*
@@ -1555,7 +1556,7 @@ static void open_netlink(void)
if (sock >= 0) {
addr.nl_family = AF_NETLINK;
addr.nl_pid = getpid();
- addr.nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;
+ addr.nl_groups = netlink_groups;
if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
close(sock);
else
@@ -1739,6 +1740,9 @@ static void print_issue_file(struct options *op, struct termios *tp)
int dd = -1, nfiles = 0, i;
struct dirent **namelist = NULL;
#endif
+#ifdef AGETTY_RELOAD
+ netlink_groups = 0;
+#endif
if ((op->flags & F_NONL) == 0) {
/* Issue not in use, start with a new line. */
write_all(STDOUT_FILENO, "\r\n", 2);
@@ -1829,6 +1833,10 @@ static void print_issue_file(struct options *op, struct termios *tp)
if (dd >= 0)
close(dd);
#endif
+#ifdef AGETTY_RELOAD
+ if (netlink_groups != 0)
+ open_netlink();
+#endif
}
#endif /* ISSUE_SUPPORT */
@@ -2633,10 +2641,6 @@ static void output_special_char(unsigned char c, struct options *op,
struct ifaddrs *addrs = NULL;
char iface[128];
-#ifdef AGETTY_RELOAD
- open_netlink();
-#endif
-
if (getifaddrs(&addrs))
break;
@@ -2646,6 +2650,11 @@ static void output_special_char(unsigned char c, struct options *op,
output_iface_ip(addrs, NULL, family);
freeifaddrs(addrs);
+
+ if (c == '4')
+ netlink_groups |= RTMGRP_IPV4_IFADDR;
+ else
+ netlink_groups |= RTMGRP_IPV6_IFADDR;
break;
}
default: