@@ -30,19 +30,27 @@ IntfMgr::IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
3030}
3131
3232void IntfMgr::setIntfIp (const string &alias, const string &opCmd,
33- const string &ipPrefixStr, const bool ipv4 )
33+ const IpPrefix &ipPrefix )
3434{
35- stringstream cmd;
36- string res;
35+ stringstream cmd;
36+ string res;
37+ string ipPrefixStr = ipPrefix.to_string ();
38+ string broadcastIpStr = ipPrefix.getBroadcastIp ().to_string ();
39+ int prefixLen = ipPrefix.getMaskLength ();
3740
38- if (ipv4 )
41+ if (ipPrefix. isV4 () )
3942 {
40- cmd << IP_CMD << " address " << opCmd << " " << ipPrefixStr << " dev " << alias;
43+ (prefixLen < 31 ) ?
44+ (cmd << IP_CMD << " address " << opCmd << " " << ipPrefixStr << " broadcast " << broadcastIpStr <<" dev " << alias) :
45+ (cmd << IP_CMD << " address " << opCmd << " " << ipPrefixStr << " dev " << alias);
4146 }
4247 else
4348 {
44- cmd << IP_CMD << " -6 address " << opCmd << " " << ipPrefixStr << " dev " << alias;
49+ (prefixLen < 127 ) ?
50+ (cmd << IP_CMD << " -6 address " << opCmd << " " << ipPrefixStr << " broadcast " << broadcastIpStr << " dev " << alias) :
51+ (cmd << IP_CMD << " -6 address " << opCmd << " " << ipPrefixStr << " dev " << alias);
4552 }
53+
4654 int ret = swss::exec (cmd.str (), res);
4755 if (ret)
4856 {
@@ -202,7 +210,7 @@ bool IntfMgr::doIntfAddrTask(const vector<string>& keys,
202210 // Set Interface IP except for lo
203211 if (!is_lo)
204212 {
205- setIntfIp (alias, " add" , ip_prefix. to_string (), ip_prefix. isV4 () );
213+ setIntfIp (alias, " add" , ip_prefix);
206214 }
207215
208216 std::vector<FieldValueTuple> fvVector;
@@ -219,7 +227,7 @@ bool IntfMgr::doIntfAddrTask(const vector<string>& keys,
219227 // Set Interface IP except for lo
220228 if (!is_lo)
221229 {
222- setIntfIp (alias, " del" , ip_prefix. to_string (), ip_prefix. isV4 () );
230+ setIntfIp (alias, " del" , ip_prefix);
223231 }
224232 m_appIntfTableProducer.del (appKey);
225233 m_stateIntfTable.del (keys[0 ] + state_db_key_delimiter + keys[1 ]);
0 commit comments