@@ -87,33 +87,53 @@ void IntfsOrch::doTask(Consumer &consumer)
87
87
}
88
88
89
89
auto it_intfs = m_syncdIntfses.find (alias);
90
- if (it_intfs == m_syncdIntfses.end () ||
91
- !m_syncdIntfses[alias].ip_addresses .contains (ip_prefix.getIp ()))
90
+ if (it_intfs == m_syncdIntfses.end ())
92
91
{
93
- if (it_intfs == m_syncdIntfses. end ( ))
92
+ if (addRouterIntfs (port ))
94
93
{
95
- if (addRouterIntfs (port))
96
- {
97
- IntfsEntry intfs_entry;
98
- intfs_entry.ref_count = 0 ;
99
- m_syncdIntfses[alias] = intfs_entry;
100
- }
101
- else
102
- {
103
- it++;
104
- continue ;
105
- }
94
+ IntfsEntry intfs_entry;
95
+ intfs_entry.ref_count = 0 ;
96
+ m_syncdIntfses[alias] = intfs_entry;
97
+ }
98
+ else
99
+ {
100
+ it++;
101
+ continue ;
106
102
}
107
-
108
- addSubnetRoute (port, ip_prefix);
109
- addIp2MeRoute (ip_prefix);
110
-
111
- m_syncdIntfses[alias].ip_addresses .add (ip_prefix.getIp ());
112
- it = consumer.m_toSync .erase (it);
113
103
}
114
- else
104
+
105
+ if (m_syncdIntfses[alias].ip_addresses .count (ip_prefix))
106
+ {
115
107
/* Duplicate entry */
116
108
it = consumer.m_toSync .erase (it);
109
+ continue ;
110
+ }
111
+
112
+ bool overlaps = false ;
113
+ for (const auto &prefixIt: m_syncdIntfses[alias].ip_addresses )
114
+ {
115
+ if (prefixIt.isAddressInSubnet (ip_prefix.getIp ()) ||
116
+ ip_prefix.isAddressInSubnet (prefixIt.getIp ()))
117
+ {
118
+ overlaps = true ;
119
+ SWSS_LOG_NOTICE (" Router interface %s IP %s overlaps with %s." , port.m_alias .c_str (),
120
+ prefixIt.to_string ().c_str (), ip_prefix.to_string ().c_str ());
121
+ break ;
122
+ }
123
+ }
124
+
125
+ if (overlaps)
126
+ {
127
+ /* Overlap of IP address network */
128
+ ++it;
129
+ continue ;
130
+ }
131
+
132
+ addSubnetRoute (port, ip_prefix);
133
+ addIp2MeRoute (ip_prefix);
134
+
135
+ m_syncdIntfses[alias].ip_addresses .insert (ip_prefix);
136
+ it = consumer.m_toSync .erase (it);
117
137
}
118
138
else if (op == DEL_COMMAND)
119
139
{
@@ -134,16 +154,16 @@ void IntfsOrch::doTask(Consumer &consumer)
134
154
135
155
if (m_syncdIntfses.find (alias) != m_syncdIntfses.end ())
136
156
{
137
- if (m_syncdIntfses[alias].ip_addresses .contains (ip_prefix. getIp () ))
157
+ if (m_syncdIntfses[alias].ip_addresses .count (ip_prefix))
138
158
{
139
159
removeSubnetRoute (port, ip_prefix);
140
160
removeIp2MeRoute (ip_prefix);
141
161
142
- m_syncdIntfses[alias].ip_addresses .remove (ip_prefix. getIp () );
162
+ m_syncdIntfses[alias].ip_addresses .erase (ip_prefix);
143
163
}
144
164
145
165
/* Remove router interface that no IP addresses are associated with */
146
- if (m_syncdIntfses[alias].ip_addresses .getSize () == 0 )
166
+ if (m_syncdIntfses[alias].ip_addresses .size () == 0 )
147
167
{
148
168
if (removeRouterIntfs (port))
149
169
{
0 commit comments