mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
Remove interface type Etherlike
Instead check if the interface support autonegotion before setting it to an interface. This fix #877 and fix #584
This commit is contained in:
@@ -56,16 +56,6 @@ EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
iftype()
|
||||
{
|
||||
iftype=$(ip -d -j link show "$1" |jq -r .[].parentbus)
|
||||
if [ "$iftype" = "virtio" ]; then
|
||||
echo "infix-if-type:etherlike"
|
||||
else
|
||||
echo "infix-if-type:ethernet"
|
||||
fi
|
||||
}
|
||||
|
||||
# shellcheck disable=SC3043
|
||||
gen_iface_json()
|
||||
{
|
||||
@@ -75,7 +65,7 @@ gen_iface_json()
|
||||
cat <<EOF
|
||||
,{
|
||||
"name": "$ifname",
|
||||
"type": "$(iftype "$ifname")",
|
||||
"type": "infix-if-type:ethernet",
|
||||
EOF
|
||||
|
||||
if [ -n "$br" ]; then
|
||||
|
||||
@@ -37,10 +37,10 @@ static int netdag_gen_ethtool_flow_control(struct dagger *net, struct lyd_node *
|
||||
const char *ifname = lydx_get_cattr(cif, "name");
|
||||
FILE *fp;
|
||||
|
||||
fp = dagger_fopen_net_init(net, ifname, NETDAG_INIT_PHYS, "ethtool-aneg.sh");
|
||||
fp = dagger_fopen_net_init(net, ifname, NETDAG_INIT_PHYS, "ethtool-flow-control.sh");
|
||||
if (!fp)
|
||||
return -EIO;
|
||||
|
||||
fprintf(fp, "[[ -n $(ethtool --json %s | jq '.[] | select(.\"supported-pause-frame-use\" == \"No\")') ]] && exit 0\n", ifname);
|
||||
fprintf(fp, "ethtool --pause %s autoneg %s rx off tx off\n",
|
||||
ifname, iface_uses_autoneg(cif) ? "on" : "off");
|
||||
fclose(fp);
|
||||
@@ -60,10 +60,10 @@ static int netdag_gen_ethtool_autoneg(struct dagger *net, struct lyd_node *cif)
|
||||
if (!fp)
|
||||
return -EIO;
|
||||
|
||||
fprintf(fp, "ethtool --change %s autoneg ", ifname);
|
||||
|
||||
if (iface_uses_autoneg(cif)) {
|
||||
fputs("on\n", fp);
|
||||
fprintf(fp, "[[ -n $(ethtool --json %s | jq '.[] | select(.\"supports-auto-negotiation\" == false)') ]] && exit 0\n", ifname);
|
||||
fprintf(fp, "ethtool --change %s autoneg on", ifname);
|
||||
} else {
|
||||
speed = lydx_get_cattr(eth, "speed");
|
||||
if (!speed) {
|
||||
@@ -93,7 +93,7 @@ static int netdag_gen_ethtool_autoneg(struct dagger *net, struct lyd_node *cif)
|
||||
goto out;
|
||||
}
|
||||
|
||||
fprintf(fp,"off speed %d duplex %s\n", mbps, duplex);
|
||||
fprintf(fp,"ethtool --change %s autoneg off speed %d duplex %s\n", ifname, mbps, duplex);
|
||||
}
|
||||
out:
|
||||
fclose(fp);
|
||||
|
||||
@@ -370,7 +370,6 @@ static int netdag_gen_afspec_add(sr_session_ctx_t *session, struct dagger *net,
|
||||
return vxlan_gen(NULL, cif, ip);
|
||||
|
||||
case IFT_ETH:
|
||||
case IFT_ETHISH:
|
||||
case IFT_LO:
|
||||
case IFT_UNKNOWN:
|
||||
sr_session_set_error_message(net->session, "%s: unsupported interface type \"%s\"",
|
||||
@@ -402,7 +401,6 @@ static int netdag_gen_afspec_set(sr_session_ctx_t *session, struct dagger *net,
|
||||
return 0;
|
||||
|
||||
case IFT_ETH:
|
||||
case IFT_ETHISH:
|
||||
case IFT_LO:
|
||||
case IFT_UNKNOWN:
|
||||
return ERR_IFACE(cif, -ENOSYS, "unsupported interface type \"%s\"",
|
||||
@@ -421,7 +419,6 @@ static bool netdag_must_del(struct lyd_node *dif, struct lyd_node *cif)
|
||||
case IFT_LO:
|
||||
break;
|
||||
case IFT_ETH:
|
||||
case IFT_ETHISH:
|
||||
/* case IFT_LAG: */
|
||||
/* ... REMEMBER WHEN ADDING BOND SUPPORT ... */
|
||||
return lydx_get_child(dif, "custom-phys-address");
|
||||
@@ -441,6 +438,7 @@ static bool netdag_must_del(struct lyd_node *dif, struct lyd_node *cif)
|
||||
ERR_IFACE(cif, -EINVAL, "unsupported interface type \"%s\"",
|
||||
lydx_get_cattr(cif, "type"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -505,7 +503,6 @@ static int netdag_gen_iface_del(struct dagger *net, struct lyd_node *dif,
|
||||
|
||||
switch (type) {
|
||||
case IFT_ETH:
|
||||
case IFT_ETHISH:
|
||||
case IFT_LO:
|
||||
eth_gen_del(dif, ip);
|
||||
break;
|
||||
@@ -665,7 +662,6 @@ static int netdag_init_iface(struct lyd_node *cif)
|
||||
|
||||
case IFT_DUMMY:
|
||||
case IFT_ETH:
|
||||
case IFT_ETHISH:
|
||||
case IFT_GRE:
|
||||
case IFT_GRETAP:
|
||||
case IFT_LO:
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
_map(IFT_BRIDGE, "infix-if-type:bridge") \
|
||||
_map(IFT_DUMMY, "infix-if-type:dummy") \
|
||||
_map(IFT_ETH, "infix-if-type:ethernet") \
|
||||
_map(IFT_ETHISH, "infix-if-type:etherlike") \
|
||||
_map(IFT_GRE, "infix-if-type:gre") \
|
||||
_map(IFT_GRETAP, "infix-if-type:gretap") \
|
||||
_map(IFT_LAG, "infix-if-type:lag") \
|
||||
|
||||
@@ -27,7 +27,7 @@ MODULES=(
|
||||
"infix-hardware@2024-04-25.yang"
|
||||
"ieee802-dot1q-types@2022-10-29.yang"
|
||||
"infix-ip@2024-09-16.yang"
|
||||
"infix-if-type@2024-10-13.yang"
|
||||
"infix-if-type@2025-02-12.yang"
|
||||
"infix-routing@2024-11-27.yang"
|
||||
"ieee802-dot1ab-lldp@2022-03-15.yang"
|
||||
"infix-lldp@2025-01-08.yang"
|
||||
|
||||
@@ -11,6 +11,11 @@ module infix-if-type {
|
||||
contact "kernelkit@googlegroups.com";
|
||||
description "Infix extensions to IANA interfaces types";
|
||||
|
||||
revision 2025-02-12 {
|
||||
description "Remove interface type etherlike.";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
revision 2024-10-13 {
|
||||
description "Add new interface type dummy.";
|
||||
reference "internal";
|
||||
@@ -58,12 +63,7 @@ module infix-if-type {
|
||||
description "Any Ethernet interfaces, regardless of speed, RFC 3635.";
|
||||
reference "RFC 3635";
|
||||
}
|
||||
identity etherlike {
|
||||
base infix-interface-type;
|
||||
base ianaift:ilan;
|
||||
description "Interface with properties resembling Ethernet";
|
||||
reference "RFC 3635";
|
||||
}
|
||||
|
||||
identity gre {
|
||||
base infix-interface-type;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user