summaryrefslogtreecommitdiffstats
path: root/src/vnet/dhcp/dhcp_proxy.c
diff options
context:
space:
mode:
authorJohn Lo <loj@cisco.com>2017-11-14 13:19:26 -0500
committerDave Barach <openvpp@barachs.net>2017-11-16 11:25:51 +0000
commit70bfcaf47779340951c1e6f169b1cedcabe708d1 (patch)
treeb6e1378942f278e914b7139d1210562d943cb680 /src/vnet/dhcp/dhcp_proxy.c
parent9d72120a6986e642c5b16c8650ad266188adf142 (diff)
Add Support of DHCP VSS Type 0 where VPN-ID is ASCII
Enhence support of DHCP VSS (Virtual Subnet Selection) to include VSS type 0 where VSS info is a NVT (Network Virtual Terminal) ASCII VPN ID where the ASCII string MUST NOT be terminated with a zero byte. Existing code already support VSS type 1, where VSS information is a RFC 2685 VPN-ID of 7 bytes with 3 bytes OUI and 4 bytes VPN index, and VSS type 255 indicating global VPN. Change-Id: I54edbc447c89a2aacd1cc9fc72bd5ba386037608 Signed-off-by: John Lo <loj@cisco.com>
Diffstat (limited to 'src/vnet/dhcp/dhcp_proxy.c')
-rw-r--r--src/vnet/dhcp/dhcp_proxy.c84
1 files changed, 61 insertions, 23 deletions
diff --git a/src/vnet/dhcp/dhcp_proxy.c b/src/vnet/dhcp/dhcp_proxy.c
index 1784906b7b3..dae631236de 100644
--- a/src/vnet/dhcp/dhcp_proxy.c
+++ b/src/vnet/dhcp/dhcp_proxy.c
@@ -278,19 +278,60 @@ dhcp_vss_show_walk (dhcp_vss_t *vss,
{
vlib_main_t * vm = ctx;
- vlib_cli_output (vm, "%=6d%=6d%=12d",
- rx_table_id,
- vss->oui,
- vss->fib_id);
+ if (vss->vss_type == VSS_TYPE_VPN_ID)
+ {
+ u32 oui = ((u32) vss->vpn_id[0] << 16) + ((u32) vss->vpn_id[1] << 8)
+ + ((u32) vss->vpn_id[2]);
+ u32 fib_id = ((u32) vss->vpn_id[3] << 24) + ((u32) vss->vpn_id[4] << 16)
+ + ((u32) vss->vpn_id[5] << 8) + ((u32) vss->vpn_id[6]);
+ vlib_cli_output (vm, " fib_table: %d oui: %d vpn_index: %d",
+ rx_table_id, oui, fib_id);
+ }
+ else if (vss->vss_type == VSS_TYPE_ASCII)
+ vlib_cli_output (vm, " fib_table: %d vpn_id: %s",
+ rx_table_id, vss->vpn_ascii_id);
+ else
+ vlib_cli_output (vm, " fib_table: %d default global vpn", rx_table_id);
return (1);
}
+void update_vss (dhcp_vss_t *v,
+ u8 vss_type,
+ u8 *vpn_ascii_id,
+ u32 oui,
+ u32 vpn_index)
+{
+ v->vss_type = vss_type;
+ if (v->vpn_ascii_id)
+ {
+ if (v->vpn_ascii_id == (u8 *) ~0)
+ v->vpn_ascii_id = 0;
+ else
+ vec_free (v->vpn_ascii_id);
+ }
+
+ if (vss_type == VSS_TYPE_ASCII)
+ v->vpn_ascii_id = vpn_ascii_id;
+ else if (vss_type == VSS_TYPE_VPN_ID)
+ {
+ v->vpn_id[0] = (oui >> 16) & 0xff;
+ v->vpn_id[1] = (oui >> 8) & 0xff;
+ v->vpn_id[2] = (oui >> 0) & 0xff;
+ v->vpn_id[3] = (vpn_index >> 24) & 0xff;
+ v->vpn_id[4] = (vpn_index >> 16) & 0xff;
+ v->vpn_id[5] = (vpn_index >> 8) & 0xff;
+ v->vpn_id[6] = (vpn_index >> 0) & 0xff;
+ }
+}
+
int dhcp_proxy_set_vss (fib_protocol_t proto,
u32 tbl_id,
+ u8 vss_type,
+ u8 *vpn_ascii_id,
u32 oui,
- u32 fib_id,
- int is_del)
+ u32 vpn_index,
+ u8 is_del)
{
dhcp_proxy_main_t *dm = &dhcp_proxy_main;
dhcp_vss_t *v = NULL;
@@ -306,43 +347,40 @@ int dhcp_proxy_set_vss (fib_protocol_t proto,
v = dhcp_get_vss_info(dm, rx_fib_index, proto);
if (NULL != v)
- {
+ {
if (is_del)
- {
+ {
/* release the lock held on the table when the VSS
* info was created */
dhcp_proxy_rx_table_unlock (proto, rx_fib_index);
+ vec_free (v->vpn_ascii_id);
pool_put (dm->vss[proto], v);
dm->vss_index_by_rx_fib_index[proto][rx_fib_index] = ~0;
- }
+ }
else
- {
- /* this is a modify */
- v->fib_id = fib_id;
- v->oui = oui;
- }
- }
+ {
+ update_vss (v, vss_type, vpn_ascii_id, oui, vpn_index);
+ }
+ }
else
- {
+ {
if (is_del)
- rc = VNET_API_ERROR_NO_SUCH_ENTRY;
+ rc = VNET_API_ERROR_NO_SUCH_ENTRY;
else
- {
+ {
/* create a new entry */
vec_validate_init_empty(dm->vss_index_by_rx_fib_index[proto],
rx_fib_index, ~0);
/* hold a lock on the table whilst the VSS info exist */
pool_get (dm->vss[proto], v);
- v->fib_id = fib_id;
- v->oui = oui;
-
+ update_vss (v, vss_type, vpn_ascii_id, oui, vpn_index);
dm->vss_index_by_rx_fib_index[proto][rx_fib_index] =
v - dm->vss[proto];
dhcp_proxy_rx_table_lock (proto, rx_fib_index);
- }
- }
+ }
+ }
/* Release the lock taken during the create_or_lock at the start */
dhcp_proxy_rx_table_unlock (proto, rx_fib_index);