Skip to content

Commit fd46fbc

Browse files
authored
Do not log error when write fails to tap device (sonic-net#278)
* Do not log error when write fails to tap device This is when one of the virtual ethernet interface is down, then EIO is returned. * Fix spelling mistake
1 parent f04e13e commit fd46fbc

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

vslib/src/sai_vs_hostintf.cpp

+30-8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ typedef struct _hostif_info_t
3434

3535
volatile bool run_thread;
3636

37+
std::string name;
38+
3739
} hostif_info_t;
3840

3941
std::map<std::string, std::shared_ptr<hostif_info_t>> hostif_info_map;
@@ -194,18 +196,32 @@ void veth2tap_fun(std::shared_ptr<hostif_info_t> info)
194196

195197
if (size < 0)
196198
{
197-
SWSS_LOG_ERROR("failed to read from socket %d", info->packet_socket);
198-
break;
199+
SWSS_LOG_ERROR("failed to read from socket fd %d, errno(%d): %s",
200+
info->packet_socket, errno, strerror(errno));
201+
202+
continue;
199203
}
200204

201205
// TODO examine packet for mac and possible generate fdb_event
202206

203207
if (write(info->tapfd, buffer, size) < 0)
204208
{
205-
SWSS_LOG_ERROR("failed to write to tap device %d", info->tapfd);
206-
break;
209+
/*
210+
* We filter out EIO because of this patch:
211+
* https://github.com/torvalds/linux/commit/1bd4978a88ac2589f3105f599b1d404a312fb7f6
212+
*/
213+
214+
if (errno != ENETDOWN && errno != EIO)
215+
{
216+
SWSS_LOG_ERROR("failed to write to tap device fd %d, errno(%d): %s",
217+
info->tapfd, errno, strerror(errno));
218+
}
219+
220+
continue;
207221
}
208222
}
223+
224+
SWSS_LOG_NOTICE("ending thread proc for %s", info->name.c_str());
209225
}
210226

211227
void tap2veth_fun(std::shared_ptr<hostif_info_t> info)
@@ -222,17 +238,22 @@ void tap2veth_fun(std::shared_ptr<hostif_info_t> info)
222238

223239
if (size < 0)
224240
{
225-
SWSS_LOG_ERROR("failed to read from tapfd: %d", info->tapfd);
241+
SWSS_LOG_ERROR("failed to read from tapfd fd %d, errno(%d): %s",
242+
info->tapfd, errno, strerror(errno));
226243

227-
break;
244+
continue;
228245
}
229246

230247
if (write(info->packet_socket, buffer, (int)size) < 0)
231248
{
232-
SWSS_LOG_ERROR("failed to write to socker %d", info->packet_socket);
233-
break;
249+
SWSS_LOG_ERROR("failed to write to socket fd %d, errno(%d): %s",
250+
info->packet_socket, errno, strerror(errno));
251+
252+
continue;
234253
}
235254
}
255+
256+
SWSS_LOG_NOTICE("ending thread proc for %s", info->name.c_str());
236257
}
237258

238259
bool hostif_create_tap_veth_forwarding(
@@ -295,6 +316,7 @@ bool hostif_create_tap_veth_forwarding(
295316
info->run_thread = true;
296317
info->e2t = std::make_shared<std::thread>(veth2tap_fun, info);
297318
info->t2e = std::make_shared<std::thread>(tap2veth_fun, info);
319+
info->name = tapname;
298320

299321
info->e2t->detach();
300322
info->t2e->detach();

0 commit comments

Comments
 (0)