@@ -25,12 +25,20 @@ IntfMgr::IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
25
25
{
26
26
}
27
27
28
- bool IntfMgr::setIntfIp (const string &alias, const string &opCmd, const string &ipPrefixStr)
28
+ bool IntfMgr::setIntfIp (const string &alias, const string &opCmd,
29
+ const string &ipPrefixStr, const bool ipv4)
29
30
{
30
31
stringstream cmd;
31
32
string res;
32
33
33
- cmd << IP_CMD << " address " << opCmd << " " << ipPrefixStr << " dev " << alias;;
34
+ if (ipv4)
35
+ {
36
+ cmd << IP_CMD << " address " << opCmd << " " << ipPrefixStr << " dev " << alias;
37
+ }
38
+ else
39
+ {
40
+ cmd << IP_CMD << " -6 address " << opCmd << " " << ipPrefixStr << " dev " << alias;
41
+ }
34
42
int ret = swss::exec (cmd.str (), res);
35
43
return (ret == 0 );
36
44
}
@@ -72,34 +80,24 @@ void IntfMgr::doTask(Consumer &consumer)
72
80
{
73
81
KeyOpFieldsValuesTuple t = it->second ;
74
82
75
- string keySeparator = CONFIGDB_KEY_SEPARATOR;
76
- vector<string> keys = tokenize (kfvKey (t), keySeparator[0 ]);
77
- string alias (keys[0 ]);
83
+ vector<string> keys = tokenize (kfvKey (t), config_db_key_delimiter);
78
84
79
- if (alias. compare ( 0 , strlen (VLAN_PREFIX), VLAN_PREFIX) )
85
+ if (keys. size () != 2 )
80
86
{
81
- /* handle IP over vlan Only for now, skip the rest */
87
+ SWSS_LOG_ERROR ( " Invalid key %s " , kfvKey (t). c_str ());
82
88
it = consumer.m_toSync .erase (it);
83
89
continue ;
84
90
}
85
91
86
- size_t pos = kfvKey (t).find (CONFIGDB_KEY_SEPARATOR);
87
- if (pos == string::npos)
88
- {
89
- SWSS_LOG_DEBUG (" Invalid key %s" , kfvKey (t).c_str ());
90
- it = consumer.m_toSync .erase (it);
91
- continue ;
92
- }
93
- IpPrefix ip_prefix (kfvKey (t).substr (pos+1 ));
94
-
95
- SWSS_LOG_DEBUG (" intfs doTask: %s" , (dumpTuple (consumer, t)).c_str ());
92
+ string alias (keys[0 ]);
93
+ IpPrefix ip_prefix (keys[1 ]);
96
94
97
95
string op = kfvOp (t);
98
96
if (op == SET_COMMAND)
99
97
{
100
98
/*
101
- * Don't proceed if port/lag /VLAN is not ready yet.
102
- * The pending task will be checked periodially and retried.
99
+ * Don't proceed if port/LAG /VLAN is not ready yet.
100
+ * The pending task will be checked periodically and retried.
103
101
* TODO: Subscribe to stateDB for port/lag/VLAN state and retry
104
102
* pending tasks immediately upon state change.
105
103
*/
@@ -109,18 +107,17 @@ void IntfMgr::doTask(Consumer &consumer)
109
107
it++;
110
108
continue ;
111
109
}
112
- string opCmd (" add" );
113
- string ipPrefixStr = ip_prefix.to_string ();
114
- setIntfIp (alias, opCmd, ipPrefixStr);
110
+ setIntfIp (alias, " add" , ip_prefix.to_string (), ip_prefix.isV4 ());
115
111
}
116
112
else if (op == DEL_COMMAND)
117
113
{
118
- string opCmd (" del" );
119
- string ipPrefixStr = ip_prefix.to_string ();
120
- setIntfIp (alias, opCmd, ipPrefixStr);
114
+ setIntfIp (alias, " del" , ip_prefix.to_string (), ip_prefix.isV4 ());
115
+ }
116
+ else
117
+ {
118
+ SWSS_LOG_ERROR (" Unknown operation: %s" , op.c_str ());
121
119
}
122
120
123
121
it = consumer.m_toSync .erase (it);
124
- continue ;
125
122
}
126
123
}
0 commit comments