Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify rcopy codes with supporting client to use specific bond ip #1538

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions librdmacm/examples/rcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
static uint64_t bytes;
static int fd;
static void *file_addr;
static char *client_bond_ip = NULL;

Check failure on line 66 in librdmacm/examples/rcopy.c

View check run for this annotation

Azure Pipelines / linux-rdma.rdma-core (Build Compile Tests)

librdmacm/examples/rcopy.c#L66

librdmacm/examples/rcopy.c(66,): error INITIALISED_STATIC: do not initialise statics to NULL

Check failure on line 66 in librdmacm/examples/rcopy.c

View check run for this annotation

Azure Pipelines / linux-rdma.rdma-core

librdmacm/examples/rcopy.c#L66

librdmacm/examples/rcopy.c(66,): error INITIALISED_STATIC: do not initialise statics to NULL

enum {
CMD_NOOP,
Expand Down Expand Up @@ -407,6 +408,21 @@
goto free;
}

// 设置本地地址
if (client_bond_ip != NULL) {
struct sockaddr_in local_addr;
memset(&local_addr, 0, sizeof(local_addr));
local_addr.sin_family = AF_INET;
local_addr.sin_addr.s_addr = inet_addr(client_bond_ip); // 设置绑定的IP地址
local_addr.sin_port = 0; // 0表示由系统自动分配端口号

ret = rs_bind(rs, (struct sockaddr *)&local_addr, sizeof(local_addr));
if (ret < 0) {
printf("rs_bind failed: %s\n", strerror(errno));
goto close;
}
}

ret = rconnect(rs, res->ai_addr, res->ai_addrlen);
if (ret) {
perror("rconnect failed\n");
Expand All @@ -417,6 +433,9 @@
free:
freeaddrinfo(res);
return rs;
close:
rclose(rs);
goto free;
}

static int client_open(int rs)
Expand Down Expand Up @@ -601,6 +620,8 @@
if (!dst_file)
dst_file = src_file;

client_bond_ip = argv[3];

while ((op = getopt(argc, argv, "p:")) != -1) {
switch (op) {
case 'p':
Expand Down
Loading