Skip to content

Commit

Permalink
Fix incorrect fd indexing in mirror mode
Browse files Browse the repository at this point in the history
  • Loading branch information
svpcom committed Sep 11, 2024
1 parent ea4f28a commit 557eef0
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,34 @@ void RawSocketTransmitter::set_mark(uint32_t idx)
return;
}

int fd = sockfds[current_output];
uint32_t sockopt = this->fwmark + idx;
if (current_output >= 0)
{
int fd = sockfds[current_output];
uint32_t sockopt = fwmark + idx;

if(setsockopt(fd, SOL_SOCKET, SO_MARK, (const void *)&sockopt , sizeof(sockopt)) !=0)
{
throw runtime_error(string_format("Unable to set SO_MARK fd(%d)=%u: %s", fd, sockopt, strerror(errno)));
}

return;
}

if(setsockopt(fd, SOL_SOCKET, SO_MARK, (const void *)&sockopt , sizeof(sockopt)) !=0)
// Handle mirror mode
for(auto it = sockfds.begin(); it != sockfds.end(); it++)
{
throw runtime_error(string_format("Unable to set SO_MARK fd(%d)=%u: %s", fd, sockopt, strerror(errno)));
int fd = *it;
uint32_t sockopt = fwmark + idx;

if(setsockopt(fd, SOL_SOCKET, SO_MARK, (const void *)&sockopt , sizeof(sockopt)) !=0)
{
throw runtime_error(string_format("Unable to set SO_MARK fd(%d)=%u: %s", fd, sockopt, strerror(errno)));
}
}
}



RawSocketTransmitter::RawSocketTransmitter(int k, int n, const string &keypair, uint64_t epoch, uint32_t channel_id, uint32_t fec_delay,
vector<tags_item_t> &tags, const vector<string> &wlans, radiotap_header_t &radiotap_header,
uint8_t frame_type, bool use_qdisc, uint32_t fwmark) : \
Expand Down

0 comments on commit 557eef0

Please sign in to comment.