Skip to content

Commit

Permalink
RDMA/core: Constify dst_addr argument
Browse files Browse the repository at this point in the history
Following APIs are not supposed to modify addr or dest_addr contents.
Therefore make those function argument const for better code
readability.

1. rdma_resolve_ip()
2. rdma_addr_size()
3. rdma_resolve_addr()

Signed-off-by: Parav Pandit <[email protected]>
Reviewed-by: Daniel Jurgens <[email protected]>
Signed-off-by: Leon Romanovsky <[email protected]>
Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
paravmellanox authored and jgunthorpe committed Jul 31, 2018
1 parent 219d2e9 commit 2df7dba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions drivers/infiniband/core/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr,
return -ENODATA;
}

int rdma_addr_size(struct sockaddr *addr)
int rdma_addr_size(const struct sockaddr *addr)
{
switch (addr->sa_family) {
case AF_INET:
Expand Down Expand Up @@ -585,7 +585,7 @@ static void process_one_req(struct work_struct *_work)
spin_unlock_bh(&lock);
}

int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr,
int rdma_resolve_ip(struct sockaddr *src_addr, const struct sockaddr *dst_addr,
struct rdma_dev_addr *addr, int timeout_ms,
void (*callback)(int status, struct sockaddr *src_addr,
struct rdma_dev_addr *addr, void *context),
Expand Down
14 changes: 7 additions & 7 deletions drivers/infiniband/core/cma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
}
EXPORT_SYMBOL(rdma_init_qp_attr);

static inline int cma_zero_addr(struct sockaddr *addr)
static inline int cma_zero_addr(const struct sockaddr *addr)
{
switch (addr->sa_family) {
case AF_INET:
Expand All @@ -1060,7 +1060,7 @@ static inline int cma_zero_addr(struct sockaddr *addr)
}
}

static inline int cma_loopback_addr(struct sockaddr *addr)
static inline int cma_loopback_addr(const struct sockaddr *addr)
{
switch (addr->sa_family) {
case AF_INET:
Expand All @@ -1074,7 +1074,7 @@ static inline int cma_loopback_addr(struct sockaddr *addr)
}
}

static inline int cma_any_addr(struct sockaddr *addr)
static inline int cma_any_addr(const struct sockaddr *addr)
{
return cma_zero_addr(addr) || cma_loopback_addr(addr);
}
Expand All @@ -1097,7 +1097,7 @@ static int cma_addr_cmp(struct sockaddr *src, struct sockaddr *dst)
}
}

static __be16 cma_port(struct sockaddr *addr)
static __be16 cma_port(const struct sockaddr *addr)
{
struct sockaddr_ib *sib;

Expand All @@ -1115,7 +1115,7 @@ static __be16 cma_port(struct sockaddr *addr)
}
}

static inline int cma_any_port(struct sockaddr *addr)
static inline int cma_any_port(const struct sockaddr *addr)
{
return !cma_port(addr);
}
Expand Down Expand Up @@ -2944,7 +2944,7 @@ static int cma_resolve_ib_addr(struct rdma_id_private *id_priv)
}

static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
struct sockaddr *dst_addr)
const struct sockaddr *dst_addr)
{
if (!src_addr || !src_addr->sa_family) {
src_addr = (struct sockaddr *) &id->route.addr.src_addr;
Expand All @@ -2965,7 +2965,7 @@ static int cma_bind_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
}

int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
struct sockaddr *dst_addr, int timeout_ms)
const struct sockaddr *dst_addr, int timeout_ms)
{
struct rdma_id_private *id_priv;
int ret;
Expand Down
4 changes: 2 additions & 2 deletions include/rdma/ib_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ int rdma_translate_ip(const struct sockaddr *addr,
* or been canceled. A status of 0 indicates success.
* @context: User-specified context associated with the call.
*/
int rdma_resolve_ip(struct sockaddr *src_addr, struct sockaddr *dst_addr,
int rdma_resolve_ip(struct sockaddr *src_addr, const struct sockaddr *dst_addr,
struct rdma_dev_addr *addr, int timeout_ms,
void (*callback)(int status, struct sockaddr *src_addr,
struct rdma_dev_addr *addr, void *context),
Expand All @@ -109,7 +109,7 @@ void rdma_copy_addr(struct rdma_dev_addr *dev_addr,
const struct net_device *dev,
const unsigned char *dst_dev_addr);

int rdma_addr_size(struct sockaddr *addr);
int rdma_addr_size(const struct sockaddr *addr);
int rdma_addr_size_in6(struct sockaddr_in6 *addr);
int rdma_addr_size_kss(struct __kernel_sockaddr_storage *addr);

Expand Down
2 changes: 1 addition & 1 deletion include/rdma/rdma_cm.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr);
* @timeout_ms: Time to wait for resolution to complete.
*/
int rdma_resolve_addr(struct rdma_cm_id *id, struct sockaddr *src_addr,
struct sockaddr *dst_addr, int timeout_ms);
const struct sockaddr *dst_addr, int timeout_ms);

/**
* rdma_resolve_route - Resolve the RDMA address bound to the RDMA identifier
Expand Down

0 comments on commit 2df7dba

Please sign in to comment.