¿Podría ser que no se detectó ningún vínculo hasta que se configuró el vínculo?

¿Podría ser que no se detectó ningún vínculo hasta que se configuró el vínculo?

¿Podría ser que el:

ethtool ethx | grep detected

¿Muestra "no se detectó ningún enlace" si bond0 aún no está configurado en el lado del sistema operativo (Linux)?

¿No muestra ethtool un estado físico?

Respuesta1

Ethtool sólo funcionará con adaptadores físicos de Ethernet. Esto significa que bond0, tun0 y cualquier otro dispositivo de red que no sea un dispositivo de red físico no funcionarán con ethtool.

$ ethtool <eth?>

Por ejemplo:

$ ethtool eth0

proporciona:

Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: on
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000001 (1)
        Link detected: yes

Respuesta2

Supongo que desea encontrar el estado del enlace de la NIC, no la condición física de tener un cable enchufado en el enchufe. (Eso podría ser imposible de descubrir).

En una búsqueda rápida, creo que ya tienes la respuesta. Abra la interfaz, espere a que encuentre un enlace, si lo hay (eso puede tardar algunos segundos), luego verifique la salida de ethtool, o carriery/o operstateen /sys/class/net/$NIC/.

ifconfig somenic upparece hacer estas dos ioctlllamadas:

ioctl(4, SIOCGIFFLAGS, {ifr_name="somenic", ifr_flags=IFF_BROADCAST|IFF_MULTICAST}) = 0
ioctl(4, SIOCSIFFLAGS, {ifr_name="somenic", ifr_flags=IFF_UP|IFF_BROADCAST|IFF_RUNNING|IFF_MULTICAST}) = 0

Es decir, estableceIFF_UP . Residencia enaquí, configurar eso es lo que realmente hace que el dispositivo se inicialice:

Luego configura el IFF_UPbit dev->flagmediante ioctl(SIOCSIFFLAGS)(Indicadores de interfaz de configuración de control de E/S de socket) para encender la interfaz.

ioctl(SIOCSIFFLAGS)Sin embargo, el último comando ( ) llama al método open para el dispositivo.

En lo que respecta al código real, el controlador tiene que realizar muchas de las mismas tareas que los controladores de caracteres y bloques. open solicita todos los recursos del sistema que necesita y le indica a la interfaz que se abra;

Hay comentarios en el mismo sentido en ele1000efuente del controlador:

/**
 * e1000e_open - Called when a network interface is made active
 * @netdev: network interface device structure
 *
 * Returns 0 on success, negative value on failure
 *                                                                                                                                                                           * The open entry point is called when a network interface is made
 * active by the system (IFF_UP).  At this point all resources needed
 * for transmit and receive operations are allocated, the interrupt
 * handler is registered with the OS, the watchdog timer is started,
 * and the stack is notified that the interface is ready.
 **/
int e1000e_open(struct net_device *netdev)  

Eso implicaría que no hay manera de encontrar de manera significativa el estado del enlace de una NIC que no seaarriba, ya que el hardware ni siquiera se inicializaría.


Por supuesto, es al menos teóricamente posible que algunos controladores se comporten de manera diferente e inicialicen el hardware antes de que alguien lo configure IFF_UP, pero eso aún no ayudaría en el caso general.

información relacionada