La Fibre

Datacenter et équipements réseaux => Routeurs => Orange fibre Remplacer la LiveBox par un routeur => Discussion démarrée par: wsw70 le 22 août 2022 à 11:22:40

Titre: comment utiliser LD_PRELOAD avec dhclient?
Posté par: wsw70 le 22 août 2022 à 11:22:40
Dans ma quête d'une installation Debian 11 en remplacement de la Livebox (les lens vers les épisodes précédents S01E01, S01E02 en bas car je ne sais pas les embedder) je voulais essayer d'utiliser LD_PRELOAD.

En me basant sur https://lafibre.info/remplacer-livebox/petit-ld_preload-pour-amateurs-de-setsockopt et après avoir compilé la lib, j'ai essayé (sur le Debian connecté à la fibre)

root@router:~/so_priority.so# SO_PRIORITY_DEBUG=1 SO_PRIORITY_VALUE=6 LD_PRELOAD=/root/so_priority.so/so_priority.so /usr/sbin/dhclient -v -cf /etc/dhcp/dhclient.conf
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

so_priority.so: setsockopt(8, SOL_SOCKET, SO_PRIORITY, 6, 4) returned 0
so_priority.so: setsockopt(9, SOL_SOCKET, SO_PRIORITY, 6, 4) returned 0
Listening on LPF/enp2s0.832/00:e2:69:59:33:a2
Sending on   LPF/enp2s0.832/00:e2:69:59:33:a2
so_priority.so: setsockopt(9, SOL_SOCKET, SO_PRIORITY, 6, 4) returned 0
Sending on   Socket/fallback
DHCPREQUEST for 86.238.84.44 on enp2s0.832 to 255.255.255.255 port 67
DHCPREQUEST for 86.238.84.44 on enp2s0.832 to 255.255.255.255 port 67
DHCPDISCOVER on enp2s0.832 to 255.255.255.255 port 67 interval 7
DHCPOFFER of 172.16.51.162 from 172.16.0.1
DHCPREQUEST for 172.16.51.162 on enp2s0.832 to 255.255.255.255 port 67
DHCPREQUEST for 172.16.51.162 on enp2s0.832 to 255.255.255.255 port 67
DHCPDISCOVER on enp2s0.832 to 255.255.255.255 port 67 interval 3
DHCPOFFER of 172.16.51.162 from 172.16.0.1
DHCPREQUEST for 172.16.51.162 on enp2s0.832 to 255.255.255.255 port 67
^C

Bon, donc ça ne marche pas, je ne reçois pas d'IP publique.

En même temps, en settant la COS à la main (ou via /etc/network/interfaces) ça marche:

root@router:~/so_priority.so# /usr/sbin/ip link set dev enp2s0.832 type vlan egress 0:6 1:0 2:2 3:3 4:4 5:5 6:6 7:7
root@router:~/so_priority.so# /usr/sbin/dhclient -v -cf /etc/dhcp/dhclient.conf
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/enp2s0.832/00:e2:69:59:33:a2
Sending on   LPF/enp2s0.832/00:e2:69:59:33:a2
Sending on   Socket/fallback
DHCPREQUEST for 86.238.84.44 on enp2s0.832 to 255.255.255.255 port 67
DHCPREQUEST for 86.238.84.44 on enp2s0.832 to 255.255.255.255 port 67
DHCPDISCOVER on enp2s0.832 to 255.255.255.255 port 67 interval 4
DHCPOFFER of 86.238.84.44 from 86.238.84.1
DHCPREQUEST for 86.238.84.44 on enp2s0.832 to 255.255.255.255 port 67
DHCPACK of 86.238.84.44 from 80.10.238.25
RTNETLINK answers: File exists
bound to 86.238.84.44 -- renewal in 75688 seconds.
root@router:~/so_priority.so# /usr/sbin/ip link set dev enp2s0.832 type vlan egress 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0

Donc voilà - comment utiliser la technique du LD_PRELOAD correctement?

---

S01E01: https://lafibre.info/remplacer-livebox/comment-configurer-systemd-networkd/
S01E02: https://lafibre.info/remplacer-livebox/quel-est-le-statut-en-aout-2022-de-loption-90-et-du-cos
Titre: comment utiliser LD_PRELOAD avec dhclient?
Posté par: zoc le 22 août 2022 à 11:41:49
LD_PRELOAD fonctionne correctement si j'en juge les traces. Par contre, la priorité socket seule ne suffit pas, il faut aussi configurer le mapping entre la priorité socket et la CoS :

#> /usr/sbin/ip link set dev enp2s0.832 type vlan egress 0:0 1:0 2:0 3:0 4:0 5:0 6:6 7:0
#> SO_PRIORITY_DEBUG=1 SO_PRIORITY_VALUE=6 LD_PRELOAD=/root/so_priority.so/so_priority.so /usr/sbin/dhclient -v -cf /etc/dhcp/dhclient.conf
Attention, c'est différent de ton second extrait : Ici on ne mappe que la priorité socket 6 vers la CoS 6, tout le reste est à zéro.
Titre: comment utiliser LD_PRELOAD avec dhclient?
Posté par: wsw70 le 22 août 2022 à 15:46:12
LD_PRELOAD fonctionne correctement si j'en juge les traces. Par contre, la priorité socket seule ne suffit pas, il faut aussi configurer le mapping entre la priorité socket et la CoS :

#> /usr/sbin/ip link set dev enp2s0.832 type vlan egress 0:0 1:0 2:0 3:0 4:0 5:0 6:6 7:0
#> SO_PRIORITY_DEBUG=1 SO_PRIORITY_VALUE=6 LD_PRELOAD=/root/so_priority.so/so_priority.so /usr/sbin/dhclient -v -cf /etc/dhcp/dhclient.conf
Attention, c'est différent de ton second extrait : Ici on ne mappe que la priorité socket 6 vers la CoS 6, tout le reste est à zéro.

MERCI. Ca marche maintenant - en rebootant mon router je récupère mon IP et le débit est très correct (j'ai perdu environ 60 Mbps/30Mbps mais ça n'a aucune importance).
Merci - c'est vraiment difficile de s'y retrouver quand on a des connaissances limitées et beaucoup d'informations datent un peu.

C'est dommage d'ailleurs qu'il n'y ait pas un wiki pour ce genre d'info.