summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0066-Valid-VLANID-should-be-1-4095-as-in-802.1VLAN-spec.patch
blob: f8f71338acd0e7ab9bd60a8f8aaf8ca897dec850 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From 07caf4cc516601c93d12bbe89b4afb0284201dff Mon Sep 17 00:00:00 2001
From: Suryakanth Sekar <suryakanth.sekar@linux.intel.com>
Date: Fri, 2 Aug 2019 14:18:31 +0530
Subject: [PATCH] Valid VLANID should be 1-4095 as in 802.1VLAN spec

Added the VLAN ID checking condition in Set LAN configuration

Unit test:
Verified VLAN ID 1-4095 is allowed  and CC returns for 0 & > 4095

Change-Id: I1737986ed7adb727758dedb84b851ba2c208cea3
Signed-off-by: Suryakanth Sekar <suryakanth.sekar@linux.intel.com>
---
 transporthandler.cpp | 4 ++++
 transporthandler.hpp | 1 +
 2 files changed, 5 insertions(+)

diff --git a/transporthandler.cpp b/transporthandler.cpp
index 44ddcef..ede6472 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -536,6 +536,10 @@ ipmi_ret_t ipmi_transport_set_lan(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
             // We assume that ipmitool always send enable
             // bit as 1.
             vlan = le16toh(vlan);
+            if (vlan == 0 || vlan > maxValidVLANIDValue)
+            {
+                return IPMI_CC_INVALID_FIELD_REQUEST;
+            }
             channelConf->vlanID = vlan;
         }
         break;
diff --git a/transporthandler.hpp b/transporthandler.hpp
index 1237658..d8805e1 100644
--- a/transporthandler.hpp
+++ b/transporthandler.hpp
@@ -219,3 +219,4 @@ enum class Privilege : uint8_t
 
 constexpr uint8_t progressMask = 0x03;
 constexpr uint8_t enableMask = 0x01;
+constexpr uint16_t maxValidVLANIDValue = 4095;
-- 
2.7.4