Skip to content
Snippets Groups Projects
Commit 320bc2f5 authored by Vladimir Saveliev's avatar Vladimir Saveliev
Browse files

Branch HEAD

b=12749
i=maxim,isaac

First of three patches for the root squash feature

This adds three functions to manipulate with lists of NID ranges:
cfs_parse_nidlist - parses nid range list and
                    creates structure of lists of [lo,hi,stride,net]
                    which can be used to check matching a NID to set of NIDs
cfs_free_nidlist - frees structures allocated on nidlist parsing
cfs_match_nid - check whether a NID matches to set of NIDs
cfs_iswhite - auxiliary function to check if a character is a whitespace

These functions have prefixes cfs_ instead of libcfs_ because of bug #17167.

Example of NID range list: 10.2.0.[1-20/2]@tcp [0,2,6]@elan0 [1,2,4-100/4]@elan1
nidlist syntax:
  <nidlist>         :== <nidrange> [ ' ' <nidrange> ]
  <nidrange>        :== <addrrange> '@' <net>
  <addrrange>       :== '*' |
                        <ipaddr_range> |
                        <numaddr_range>
  <ipaddr_range>    :== <numaddr_range>.<numaddr_range>.<numaddr_range>.<numaddr_range>
  <numaddr_range>   :== <number> |
                        <expr_list>
  <expr_list>       :== '[' <range_expr> [ ',' <range_expr>] ']'
  <range_expr>      :== <number> |
                        <number> '-' <number> |
                        <number> '-' <number> '/' <number>
  <net>             :== <netname> | <netname><number>
  <netname>         :== "lo" | "tcp" | "o2ib" | "cib" | "openib" | "iib" |
                        "vib" | "ra" | "elan" | "gm" | "mx" | "ptl"
  <number>          :== <nonnegative decimal> | <hexadecimal>
parent be65cc14
No related branches found
No related tags found
No related merge requests found
...@@ -312,6 +312,10 @@ __u32 libcfs_str2net(const char *str); ...@@ -312,6 +312,10 @@ __u32 libcfs_str2net(const char *str);
lnet_nid_t libcfs_str2nid(const char *str); lnet_nid_t libcfs_str2nid(const char *str);
int libcfs_str2anynid(lnet_nid_t *nid, const char *str); int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
char *libcfs_id2str(lnet_process_id_t id); char *libcfs_id2str(lnet_process_id_t id);
int cfs_iswhite(char c);
void cfs_free_nidlist(struct list_head *list);
int cfs_parse_nidlist(char *str, int len, struct list_head *list);
int cfs_match_nid(lnet_nid_t nid, struct list_head *list);
/* how an LNET NID encodes net:address */ /* how an LNET NID encodes net:address */
#define LNET_NIDADDR(nid) ((__u32)((nid) & 0xffffffff)) #define LNET_NIDADDR(nid) ((__u32)((nid) & 0xffffffff))
...@@ -322,6 +326,9 @@ char *libcfs_id2str(lnet_process_id_t id); ...@@ -322,6 +326,9 @@ char *libcfs_id2str(lnet_process_id_t id);
#define LNET_NETTYP(net) (((net) >> 16) & 0xffff) #define LNET_NETTYP(net) (((net) >> 16) & 0xffff)
#define LNET_MKNET(typ,num) ((((__u32)(typ))<<16)|((__u32)(num))) #define LNET_MKNET(typ,num) ((((__u32)(typ))<<16)|((__u32)(num)))
/* max value for numeric network address */
#define MAX_NUMERIC_VALUE 0xffffffff
/* implication */ /* implication */
#define ergo(a, b) (!(a) || (b)) #define ergo(a, b) (!(a) || (b))
/* logical equivalence */ /* logical equivalence */
......
This diff is collapsed.
...@@ -86,31 +86,17 @@ lnet_issep (char c) ...@@ -86,31 +86,17 @@ lnet_issep (char c)
} }
} }
int
lnet_iswhite (char c)
{
switch (c) {
case ' ':
case '\t':
case '\n':
case '\r':
return 1;
default:
return 0;
}
}
char * char *
lnet_trimwhite(char *str) lnet_trimwhite(char *str)
{ {
char *end; char *end;
while (lnet_iswhite(*str)) while (cfs_iswhite(*str))
str++; str++;
end = str + strlen(str); end = str + strlen(str);
while (end > str) { while (end > str) {
if (!lnet_iswhite(end[-1])) if (!cfs_iswhite(end[-1]))
break; break;
end--; end--;
} }
...@@ -394,7 +380,7 @@ lnet_str2tbs_sep (struct list_head *tbs, char *str) ...@@ -394,7 +380,7 @@ lnet_str2tbs_sep (struct list_head *tbs, char *str)
/* Split 'str' into separate commands */ /* Split 'str' into separate commands */
for (;;) { for (;;) {
/* skip leading whitespace */ /* skip leading whitespace */
while (lnet_iswhite(*str)) while (cfs_iswhite(*str))
str++; str++;
/* scan for separator or comment */ /* scan for separator or comment */
...@@ -411,7 +397,7 @@ lnet_str2tbs_sep (struct list_head *tbs, char *str) ...@@ -411,7 +397,7 @@ lnet_str2tbs_sep (struct list_head *tbs, char *str)
} }
for (i = 0; i < nob; i++) for (i = 0; i < nob; i++)
if (lnet_iswhite(str[i])) if (cfs_iswhite(str[i]))
ltb->ltb_text[i] = ' '; ltb->ltb_text[i] = ' ';
else else
ltb->ltb_text[i] = str[i]; ltb->ltb_text[i] = str[i];
...@@ -586,7 +572,7 @@ lnet_parse_route (char *str, int *im_a_router) ...@@ -586,7 +572,7 @@ lnet_parse_route (char *str, int *im_a_router)
sep = str; sep = str;
for (;;) { for (;;) {
/* scan for token start */ /* scan for token start */
while (lnet_iswhite(*sep)) while (cfs_iswhite(*sep))
sep++; sep++;
if (*sep == 0) { if (*sep == 0) {
if (ntokens < (got_hops ? 3 : 2)) if (ntokens < (got_hops ? 3 : 2))
...@@ -598,7 +584,7 @@ lnet_parse_route (char *str, int *im_a_router) ...@@ -598,7 +584,7 @@ lnet_parse_route (char *str, int *im_a_router)
token = sep++; token = sep++;
/* scan for token end */ /* scan for token end */
while (*sep != 0 && !lnet_iswhite(*sep)) while (*sep != 0 && !cfs_iswhite(*sep))
sep++; sep++;
if (*sep != 0) if (*sep != 0)
*sep++ = 0; *sep++ = 0;
...@@ -946,7 +932,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip) ...@@ -946,7 +932,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
sep = tokens; sep = tokens;
for (;;) { for (;;) {
/* scan for token start */ /* scan for token start */
while (lnet_iswhite(*sep)) while (cfs_iswhite(*sep))
sep++; sep++;
if (*sep == 0) if (*sep == 0)
break; break;
...@@ -954,7 +940,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip) ...@@ -954,7 +940,7 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
token = sep++; token = sep++;
/* scan for token end */ /* scan for token end */
while (*sep != 0 && !lnet_iswhite(*sep)) while (*sep != 0 && !cfs_iswhite(*sep))
sep++; sep++;
if (*sep != 0) if (*sep != 0)
*sep++ = 0; *sep++ = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment