mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
lan: Fix processing disabled VLAN
Before this fix `ipmitool` would complain that VLAN ID is out of range when trying to disable an already disabled VLAN on a lan channel. With this fix it will properly report that VLAN is already disabled. Resolves ipmitool/ipmitool#55 Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
parent
6c3d4b56c9
commit
6e2b688e24
@ -50,6 +50,13 @@
|
||||
#define IPMI_LANP_WRITE_LOCK 1
|
||||
#define IPMI_LANP_WRITE_COMMIT 2
|
||||
|
||||
#define IPMI_LANP_VLAN_ID_MAX 4094
|
||||
#define IPMI_LANP_VLAN_ID_MIN 1
|
||||
#define IPMI_LANP_VLAN_DISABLE 0 /* ID 0 = VLAN is disabled for the channel */
|
||||
|
||||
#define IPMI_LANP_IS_VLAN_VALID(x) \
|
||||
((x) >= IPMI_LANP_VLAN_ID_MIN && (x) <= IPMI_LANP_VLAN_ID_MAX)
|
||||
|
||||
enum {
|
||||
IPMI_LANP_SET_IN_PROGRESS,
|
||||
IPMI_LANP_AUTH_TYPE,
|
||||
|
@ -1204,18 +1204,27 @@ ipmi_lan_set_vlan_id(struct ipmi_intf *intf, uint8_t chan, char *string)
|
||||
{
|
||||
struct lan_param *p;
|
||||
uint8_t data[2];
|
||||
int rc;
|
||||
int rc = -1;
|
||||
|
||||
if (!string) {
|
||||
if (!string) { /* request to disable VLAN */
|
||||
lprintf(LOG_DEBUG, "Get current VLAN ID from BMC.");
|
||||
p = get_lan_param(intf, chan, IPMI_LANP_VLAN_ID);
|
||||
if (p && p->data && p->data_len > 1) {
|
||||
int id = ((p->data[1] & 0x0f) << 8) + p->data[0];
|
||||
if (id < 1 || id > 4094) {
|
||||
if (IPMI_LANP_VLAN_DISABLE == id) {
|
||||
printf("VLAN is already disabled for channel %"
|
||||
PRIu8 "\n", chan);
|
||||
rc = 0;
|
||||
goto out;
|
||||
}
|
||||
if (IPMI_LANP_IS_VLAN_VALID(id)) {
|
||||
lprintf(LOG_ERR,
|
||||
"Retrieved VLAN ID %i is out of range <1..4094>.",
|
||||
id);
|
||||
return (-1);
|
||||
"Retrieved VLAN ID %i is out of "
|
||||
"range <%d..%d>.",
|
||||
id,
|
||||
IPMI_LANP_VLAN_ID_MIN,
|
||||
IPMI_LANP_VLAN_ID_MAX);
|
||||
goto out;
|
||||
}
|
||||
data[0] = p->data[0];
|
||||
data[1] = p->data[1] & 0x0F;
|
||||
@ -1227,13 +1236,18 @@ ipmi_lan_set_vlan_id(struct ipmi_intf *intf, uint8_t chan, char *string)
|
||||
else {
|
||||
int id = 0;
|
||||
if (str2int(string, &id) != 0) {
|
||||
lprintf(LOG_ERR, "Given VLAN ID '%s' is invalid.", string);
|
||||
return (-1);
|
||||
lprintf(LOG_ERR,
|
||||
"Given VLAN ID '%s' is invalid.",
|
||||
string);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (id < 1 || id > 4094) {
|
||||
lprintf(LOG_NOTICE, "VLAN ID must be between 1 and 4094.");
|
||||
return (-1);
|
||||
if (IPMI_LANP_IS_VLAN_VALID(id)) {
|
||||
lprintf(LOG_NOTICE,
|
||||
"VLAN ID must be between %d and %d.",
|
||||
IPMI_LANP_VLAN_ID_MIN,
|
||||
IPMI_LANP_VLAN_ID_MAX);
|
||||
goto out;
|
||||
}
|
||||
else {
|
||||
data[0] = (uint8_t)id;
|
||||
@ -1241,6 +1255,8 @@ ipmi_lan_set_vlan_id(struct ipmi_intf *intf, uint8_t chan, char *string)
|
||||
}
|
||||
}
|
||||
rc = set_lan_param(intf, chan, IPMI_LANP_VLAN_ID, data, 2);
|
||||
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user