Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/sysinst When not invoked via some explicit "configu...



details:   https://anonhg.NetBSD.org/src/rev/dff1f484ce09
branches:  trunk
changeset: 366205:dff1f484ce09
user:      martin <martin%NetBSD.org@localhost>
date:      Wed May 18 16:39:03 2022 +0000

description:
When not invoked via some explicit "configure network" menu item,
auto-detect an already working network setup and offer to "just use" it
whenver we need connectivity.

diffstat:

 usr.sbin/sysinst/configmenu.c |   4 +-
 usr.sbin/sysinst/defs.h       |   4 +-
 usr.sbin/sysinst/menus.mi     |  10 +++---
 usr.sbin/sysinst/msg.mi.de    |   7 ++++-
 usr.sbin/sysinst/msg.mi.en    |   7 ++++-
 usr.sbin/sysinst/msg.mi.es    |   7 ++++-
 usr.sbin/sysinst/msg.mi.fr    |   7 ++++-
 usr.sbin/sysinst/msg.mi.pl    |   7 ++++-
 usr.sbin/sysinst/net.c        |  62 +++++++++++++++++++++++++++++++++++++++++-
 usr.sbin/sysinst/util.c       |   6 ++--
 10 files changed, 102 insertions(+), 19 deletions(-)

diffs (truncated from 302 to 300 lines):

diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/configmenu.c
--- a/usr.sbin/sysinst/configmenu.c     Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/configmenu.c     Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: configmenu.c,v 1.16 2022/05/15 16:38:25 jmcneill Exp $ */
+/* $NetBSD: configmenu.c,v 1.17 2022/05/18 16:39:03 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -230,7 +230,7 @@
 set_network(struct menudesc *menu, void *arg)
 {
        network_up = 0;
-       if (config_network())
+       if (config_network(1))
                mnt_net_config();
        return 0;
 }
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/defs.h   Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.81 2022/04/21 17:30:15 martin Exp $ */
+/*     $NetBSD: defs.h,v 1.82 2022/05/18 16:39:03 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -789,7 +789,7 @@
 extern char net_namesvr[STRSIZE];
 int    get_via_ftp(unsigned int);
 int    get_via_nfs(void);
-int    config_network(void);
+int    config_network(int force);
 void   mnt_net_config(void);
 void   make_url(char *, struct ftpinfo *, const char *);
 int    get_pkgsrc(void);
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/menus.mi
--- a/usr.sbin/sysinst/menus.mi Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/menus.mi Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: menus.mi,v 1.24 2020/11/04 14:29:40 martin Exp $       */
+/*     $NetBSD: menus.mi,v 1.25 2022/05/18 16:39:03 martin Exp $       */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -277,7 +277,7 @@
                action {
                        extern int network_up;
                        network_up = 0;
-                       config_network();
+                       config_network(1);
                };
        option MSG_Partition_a_disk,
                action {
@@ -407,7 +407,7 @@
                action {
                        extern int network_up;
                        network_up = 0;
-                       config_network();
+                       config_network(1);
                };
        option MSG_exit_menu_generic, exit, action { ((arg_rv*)arg)->rv = SET_RETRY; };
 
@@ -428,7 +428,7 @@
                action {
                        extern int network_up;
                        network_up = 0;
-                       config_network();
+                       config_network(1);
                };
        option MSG_exit_menu_generic, exit, action { *((int*)arg) = SET_RETRY; };
 
@@ -593,7 +593,7 @@
                action {
                        extern int network_up;
                        network_up = 0;
-                       config_network();
+                       config_network(1);
                        mnt_net_config();
                };
        option {src_legend(menu, MSG_transfer_method, url_proto(pkg.xfer));},
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/msg.mi.de
--- a/usr.sbin/sysinst/msg.mi.de        Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/msg.mi.de        Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.de,v 1.37 2022/05/16 18:44:38 martin Exp $      */
+/*     $NetBSD: msg.mi.de,v 1.38 2022/05/18 16:39:03 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1556,3 +1556,8 @@
 message clone_target_disp              {duplizierte Partition(en)}
 message clone_src_done
 {Quellauswahl OK, weiter mit der Zielauswahl}
+
+message network_ok
+{Ihr Netzwerk scheint bereits zu funktionieren. 
+Möchten Sie die Konfiguration überspringen 
+und die bisherigen Einstellungen verwenden?}
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/msg.mi.en
--- a/usr.sbin/sysinst/msg.mi.en        Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/msg.mi.en        Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.en,v 1.40 2022/05/16 18:44:38 martin Exp $      */
+/*     $NetBSD: msg.mi.en,v 1.41 2022/05/18 16:39:03 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1493,3 +1493,8 @@
 message clone_target_disp              {cloned partition(s)}
 message clone_src_done
 {Source selection OK, proceed to target selection}
+
+message network_ok
+{Your network seems to work fine. 
+Should we skip the configuration 
+and just use the network as-is?}
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/msg.mi.es
--- a/usr.sbin/sysinst/msg.mi.es        Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/msg.mi.es        Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.es,v 1.33 2022/05/16 18:44:38 martin Exp $      */
+/*     $NetBSD: msg.mi.es,v 1.34 2022/05/18 16:39:03 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1541,3 +1541,8 @@
 message clone_target_disp              {cloned partition(s)}
 message clone_src_done
 {Source selection OK, proceed to target selection}
+
+message network_ok
+{Your network seems to work fine. 
+Should we skip the configuration 
+and just use the network as-is?}
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/msg.mi.fr
--- a/usr.sbin/sysinst/msg.mi.fr        Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/msg.mi.fr        Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.fr,v 1.38 2022/05/16 18:44:38 martin Exp $      */
+/*     $NetBSD: msg.mi.fr,v 1.39 2022/05/18 16:39:03 martin Exp $      */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1572,3 +1572,8 @@
 message clone_target_disp              {cloned partition(s)}
 message clone_src_done
 {Source selection OK, proceed to target selection}
+
+message network_ok
+{Your network seems to work fine. 
+Should we skip the configuration 
+and just use the network as-is?}
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/msg.mi.pl
--- a/usr.sbin/sysinst/msg.mi.pl        Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/msg.mi.pl        Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg.mi.pl,v 1.39 2022/05/16 18:44:38 martin Exp $      */
+/*     $NetBSD: msg.mi.pl,v 1.40 2022/05/18 16:39:03 martin Exp $      */
 /*     Based on english version: */
 /*     NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp       */
 
@@ -1478,3 +1478,8 @@
 message clone_target_disp              {cloned partition(s)}
 message clone_src_done
 {Source selection OK, proceed to target selection}
+
+message network_ok
+{Your network seems to work fine. 
+Should we skip the configuration 
+and just use the network as-is?}
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/net.c
--- a/usr.sbin/sysinst/net.c    Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/net.c    Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: net.c,v 1.42 2022/05/15 17:42:32 jmcneill Exp $        */
+/*     $NetBSD: net.c,v 1.43 2022/05/18 16:39:03 martin Exp $  */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -48,6 +48,10 @@
 #include <net/if_media.h>
 #include <netinet/in.h>
 #include <net80211/ieee80211_ioctl.h>
+#include <netinet/ip_var.h>
+#ifdef INET6
+#include <netinet6/ip6_var.h>
+#endif
 
 #include <err.h>
 #include <stdio.h>
@@ -225,6 +229,50 @@
        NULL,
 };
 
+static bool
+have_working_ipv4(void)
+{
+       uint64_t ipstats[IP_NSTATS];
+       size_t size = sizeof(ipstats);
+
+       /* At least some packets delivered to upper layers? */
+       if (sysctlbyname("net.inet.ip.stats", ipstats, &size, NULL, 0) == -1)
+               return false;
+       if (ipstats[IP_STAT_DELIVERED] < 10)    /* arbitrary threshold */
+               return false;
+
+       /* do we have a default route? */
+       if (run_program(RUN_SILENT|RUN_ERROR_OK,
+           "/sbin/route  get -inet default") != 0)
+               return false;
+
+       return true;
+}
+
+#ifdef INET6
+static bool
+have_working_ipv6(void)
+{
+       uint64_t ipstats[IP6_NSTATS];
+       size_t size = sizeof(ipstats);
+
+       /* At least some packets delivered to upper layers? */
+       if (sysctlbyname("net.inet6.ip6.stats", ipstats, &size, NULL, 0) == -1)
+               return false;
+       if (ipstats[IP6_STAT_DELIVERED] < 10)   /* arbitrary threshold */
+               return false;
+
+       /* do we have a default route? */
+       if (run_program(RUN_SILENT|RUN_ERROR_OK,
+           "/sbin/route  get -inet6 default") != 0)
+               return false;
+
+       return true;
+}
+#else
+#define        have_working_ipv6()     false
+#endif
+
 static int
 get_ifconfig_info(struct net_desc *devs)
 {
@@ -483,7 +531,7 @@
  * make sure both the gateway and the name server are up.
  */
 int
-config_network(void)
+config_network(int force)
 {
        char *textbuf;
        int  octet0;
@@ -519,6 +567,13 @@
                return -1;
        }
 
+       if (!force && (have_working_ipv4() || have_working_ipv6())) {
+               if (ask_yesno(MSG_network_ok)) {
+                       network_up = 1;
+                       return 1;
+               }
+       }
+
        net_menu = calloc(num_devs, sizeof(*net_menu));
        if (net_menu == NULL) {
                err_msg_win(err_outofmem);
@@ -972,6 +1027,9 @@
 {
        arg_rv arg;
 
+       if (!network_up)
+               config_network(0);
+
        arg.rv = -1;
        arg.arg = (void*)(uintptr_t)(xfer);
        process_menu(MENU_ftpsource, &arg);
diff -r 8d3c6f6d3f1f -r dff1f484ce09 usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Wed May 18 15:20:18 2022 +0000
+++ b/usr.sbin/sysinst/util.c   Wed May 18 16:39:03 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.66 2022/04/21 17:30:15 martin Exp $ */
+/*     $NetBSD: util.c,v 1.67 2022/05/18 16:39:03 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1225,7 +1225,7 @@
        case 2:
 #ifndef DEBUG
                if (!network_up)
-                       config_network();
+                       config_network(0);
 #endif
                server.xfer = rv == 1 ? XFER_HTTP : XFER_FTP;
                arg.arg = &server;
@@ -1251,7 +1251,7 @@
        case 3:
 #ifndef DEBUG
                if (!network_up)
-                       config_network();
+                       config_network(0);
 #endif



Home | Main Index | Thread Index | Old Index