From: sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH 12/16] ibacm: add/remove addr's in EP's when added/removed from the system.
Date: Thu, 27 Mar 2014 22:50:06 -0700 [thread overview]
Message-ID: <1395985810-23822-13-git-send-email-sean.hefty@intel.com> (raw)
In-Reply-To: <1395985810-23822-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
From: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
This builds on the previous patch by reacting to the IP address changes
monitored there.
Signed-off-by: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
src/acm.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 110 insertions(+), 2 deletions(-)
diff --git a/src/acm.c b/src/acm.c
index a23e953..a83dc22 100644
--- a/src/acm.c
+++ b/src/acm.c
@@ -795,6 +795,27 @@ out:
lock_release(&ep->lock);
}
+static void acm_mark_addr_invalid(struct acm_ep *ep,
+ struct acm_ep_addr_data *data)
+{
+ int i;
+
+ lock_acquire(&ep->lock);
+ for (i = 0; i < MAX_EP_ADDR; i++) {
+ if (ep->addr_type[i] != data->type)
+ continue;
+
+ if ((data->type == ACM_ADDRESS_NAME &&
+ !strnicmp((char *) ep->addr[i].name,
+ (char *) data->info.addr, ACM_MAX_ADDRESS)) ||
+ !memcmp(ep->addr[i].addr, data->info.addr, ACM_MAX_ADDRESS)) {
+ ep->addr_type[i] = ACM_ADDRESS_INVALID;
+ break;
+ }
+ }
+ lock_release(&ep->lock);
+}
+
static int acm_addr_index(struct acm_ep *ep, uint8_t *addr, uint8_t addr_type)
{
int i;
@@ -3371,6 +3392,82 @@ static void acm_port_down(struct acm_port *port)
acm_log(1, "%s %d is down\n", port->dev->verbs->device->name, port->port_num);
}
+static int acm_nl_to_addr_data(struct acm_ep_addr_data *ad,
+ int af_family, uint8_t *addr, size_t addr_len)
+{
+ if (addr_len > ACM_MAX_ADDRESS)
+ return EINVAL;
+
+ /* find the ep associated with this address "if any" */
+ switch (af_family) {
+ case AF_INET:
+ ad->type = ACM_ADDRESS_IP;
+ break;
+ case AF_INET6:
+ ad->type = ACM_ADDRESS_IP6;
+ break;
+ default:
+ return EINVAL;
+ }
+ memcpy(&ad->info.addr, addr, addr_len);
+ return 0;
+}
+
+static void acm_add_ep_ip(struct acm_ep_addr_data *data, char *ifname)
+{
+ struct acm_ep *ep;
+ struct acm_device *dev;
+ uint8_t port_num;
+ uint16_t pkey;
+ union ibv_gid sgid;
+
+ ep = acm_get_ep(data);
+ if (ep) {
+ acm_format_name(1, log_data, sizeof log_data,
+ data->type, data->info.addr, sizeof data->info.addr);
+ acm_log(1, "Address '%s' already available\n", log_data);
+ return;
+ }
+
+ if (acm_if_get_sgid(ifname, &sgid))
+ return;
+
+ dev = acm_get_device_from_gid(&sgid, &port_num);
+ if (!dev)
+ return;
+
+ if (acm_if_get_pkey(ifname, &pkey))
+ return;
+
+ acm_format_name(0, log_data, sizeof log_data,
+ data->type, data->info.addr, sizeof data->info.addr);
+ acm_log(0, " %s\n", log_data);
+
+ ep = acm_find_ep(&dev->port[port_num-1], pkey);
+ if (ep) {
+ if (acm_ep_insert_addr(ep, data->info.addr, sizeof data->info.addr, data->type)) {
+ acm_format_name(0, log_data, sizeof log_data,
+ data->type, data->info.addr, sizeof data->info.addr);
+ acm_log(0, "Failed to add '%s' to EP\n", log_data);
+ }
+ } else {
+ acm_log(0, "Failed to add '%s' no EP for pkey\n", log_data);
+ }
+}
+
+static void acm_rm_ep_ip(struct acm_ep_addr_data *data)
+{
+ struct acm_ep *ep;
+
+ ep = acm_get_ep(data);
+ if (ep) {
+ acm_format_name(0, log_data, sizeof log_data,
+ data->type, data->info.addr, sizeof data->info.addr);
+ acm_log(0, " %s\n", log_data);
+ acm_mark_addr_invalid(ep, data);
+ }
+}
+
#define NL_MSG_BUF_SIZE 4096
static void CDECL_FUNC acm_ipnl_handler(void *context)
@@ -3403,6 +3500,7 @@ static void CDECL_FUNC acm_ipnl_handler(void *context)
struct ifinfomsg *ifi = (struct ifinfomsg *) NLMSG_DATA(nlh);
struct rtattr *rth = IFA_RTA(ifa);
int rtl = IFA_PAYLOAD(nlh);
+ struct acm_ep_addr_data ad;
switch (nlh->nlmsg_type) {
case RTM_NEWADDR:
@@ -3410,9 +3508,14 @@ static void CDECL_FUNC acm_ipnl_handler(void *context)
if_indextoname(ifa->ifa_index, name);
while (rtl && RTA_OK(rth, rtl)) {
if (rth->rta_type == IFA_LOCAL) {
- acm_log(0, "Address added %s : %s\n",
+ acm_log(1, "New system address available %s : %s\n",
name, inet_ntop(ifa->ifa_family, RTA_DATA(rth),
ip_str, sizeof(ip_str)));
+ if (!acm_nl_to_addr_data(&ad, ifa->ifa_family,
+ RTA_DATA(rth),
+ RTA_PAYLOAD(rth))) {
+ acm_add_ep_ip(&ad, name);
+ }
}
rth = RTA_NEXT(rth, rtl);
}
@@ -3423,9 +3526,14 @@ static void CDECL_FUNC acm_ipnl_handler(void *context)
if_indextoname(ifa->ifa_index, name);
while (rtl && RTA_OK(rth, rtl)) {
if (rth->rta_type == IFA_LOCAL) {
- acm_log(0, "Address deleted %s : %s\n",
+ acm_log(1, "System address removed %s : %s\n",
name, inet_ntop(ifa->ifa_family, RTA_DATA(rth),
ip_str, sizeof(ip_str)));
+ if (!acm_nl_to_addr_data(&ad, ifa->ifa_family,
+ RTA_DATA(rth),
+ RTA_PAYLOAD(rth))) {
+ acm_rm_ep_ip(&ad);
+ }
}
rth = RTA_NEXT(rth, rtl);
}
--
1.7.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-03-28 5:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-28 5:49 [PATCH 00/16] ibacm: Implement dynamic IP support sean.hefty-ral2JQCrhuEAvxtiuMwx3w
[not found] ` <1395985810-23822-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-28 5:49 ` [PATCH 01/16] ibacm: get_devaddr remove unused variable from signature sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:49 ` [PATCH 02/16] ibacm: pass interface name rather than 'struct ifreq' to get_devaddr, get_sgid, and get_pkey sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:49 ` [PATCH 03/16] ibacm: use sysfs (in acm_if_is_ib) rather than ioctl(... SIOCGIFHWADDR ...) to read interface type sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:49 ` [PATCH 04/16] ibacm: move sysfs helper functions to acm_util 'module' sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:49 ` [PATCH 05/16] ibacm: Move calling of helper functions out of get_devaddr sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 06/16] ibacm: move acm_if_iter_sys to acm_util.c sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 07/16] ibacm: convert logging in acm_util.c to acm_log sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 08/16] ibacm: add separate acm_ep_insert_addr function sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 09/16] ibacm: read system IP's into endpoints at startup sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 10/16] ibacm: add locking around end point address arrays sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 11/16] ibacm: Add thread to monitor IP address changes sean.hefty-ral2JQCrhuEAvxtiuMwx3w
[not found] ` <1395985810-23822-12-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-28 6:43 ` Bart Van Assche
[not found] ` <53351A0D.1010007-HInyCGIudOg@public.gmane.org>
2014-03-28 15:51 ` Weiny, Ira
[not found] ` <2807E5FD2F6FDA4886F6618EAC48510E04B34C7A-8k97q/ur5Z2krb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-03-28 16:23 ` Bart Van Assche
2014-03-28 5:50 ` sean.hefty-ral2JQCrhuEAvxtiuMwx3w [this message]
2014-03-28 5:50 ` [PATCH 13/16] ibacm: fix handling of aliased IPoIB devices sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 14/16] ibacm: ib_acme remove IP addresses from ibacm_addr.cfg file generation sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 15/16] ibacm: remove acm_if_iter_sys function sean.hefty-ral2JQCrhuEAvxtiuMwx3w
2014-03-28 5:50 ` [PATCH 16/16] ibacm: remove processing of IP's from ibacm_addr.cfg sean.hefty-ral2JQCrhuEAvxtiuMwx3w
[not found] ` <1395985810-23822-17-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-03-28 16:37 ` Hefty, Sean
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395985810-23822-13-git-send-email-sean.hefty@intel.com \
--to=sean.hefty-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox