Update the header comment to accurately reflect that the device IP is now obtained from udev's ID_PATH property. Additionally, move the header comment block to the top of the file, remove redundant empty comments, and convert style to c++.
Cc: Arnaldo Viegas de Lima <[email protected]> Cc: Martin Wilck <[email protected]> Cc: Benjamin Marzinski <[email protected]> Cc: Christophe Varoqui <[email protected]> Cc: DM_DEVEL-ML <[email protected]> Signed-off-by: Xose Vazquez Perez <[email protected]> --- libmultipath/prioritizers/iet.c | 65 +++++++++++++-------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/libmultipath/prioritizers/iet.c b/libmultipath/prioritizers/iet.c index 10152402..a048732b 100644 --- a/libmultipath/prioritizers/iet.c +++ b/libmultipath/prioritizers/iet.c @@ -1,3 +1,26 @@ +// This prioritizer allows path selection based on target IP address +// +// (It's a bit of a misnomer since supports the client side [eg. open-iscsi] +// instead of just "iet".) +// +// Usage: +// prio "iet" +// with either: +// prio_args "preferredip=<IP address>" +// assigns priority 20 (high) to the preferred IP and priority 10 +// (low) to the rest. +// or +// prio_args "ippriorities=<IP|CIDR>:Prio,<IP|CIDR>:Prio,..." +// IP can be specified directly or in CIDR notation (IP/32) +// CIDR can use standard n.n.n.n/p format or any valid shorthand +// 0.0.0.0/0 to set the "no match" priority (defaults to 10). +// +// Uses udev's ID_PATH property to find the IP of the device. +// Matching follows network routing semantics (more specific CIDR match wins). +// +// by Olivier Lambert <lambert.olivier.gmail.com> +// Extended "preferredip" added by Arnaldo Viegas de Lima <arnaldo.viegasdelima.com> + #include "debug.h" #include "prio.h" #include "structs.h" @@ -15,32 +38,6 @@ #include <sys/types.h> #include <unistd.h> -// -// This prioritizer allows path selection based on target IP address -// -// (It's a bit of a misnomer since supports the client side [eg. open-iscsi] -// instead of just "iet".) -// -// Usage: -// prio "iet" -// with either: -// prio_args "preferredip=<IP address>" -// assigns priority 20 (high) to the preferred IP and priority 10 -//(low) to the rest -// or -// prio_args "ippriorities=<IP|CIDR>:Prio,<IP|CIDR>:Prio,..." -// IP can be specified directly or in CIDR notation (IP/32) -// CIDR can use standard n.n.n.n/p format or any valid shorthand -// 0.0.0.0/0 to set the "no match" priority (defaults to 10) -// -// Uses /dev/disk/by-path to find the IP of the device. -// Matching follows network routing semantics (more specific match wins) -// -// by Olivier Lambert <lambert.olivier.gmail.com> -// Extended "preferredip" added by Arnaldo Viegas de Lima -// (arnaldo.viegasdelima.com) -// - #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L #define dc_log(prio, fmt, ...) condlog(prio, "%s " fmt, sysname, __VA_ARGS__) #else /* GCC extension */ @@ -50,7 +47,6 @@ #define DEFAULT_PRIORITY 10 #define DEFAULT_HIGH_PRIORITY 20 -// // Entry for the CIDR to priority list struct ipprio_entry { uint32_t network; @@ -59,7 +55,6 @@ struct ipprio_entry { struct ipprio_entry *next; }; -// // name: find_regex // @param string: string you want to search into // @param regex: the pattern used @@ -101,7 +96,6 @@ char *find_regex(const char *string, const char *regex) return NULL; } -// // name: prefix_to_mask // @param prefix: CIDR prefix (# of bits) // @return: corresponding network mask (defaults to 32 bits) @@ -114,7 +108,6 @@ static uint32_t prefix_to_mask(int prefix) return 0xffffffffU << (32 - prefix); } -// // name: parse_cidr // @param s: string containing CIDR block or single IP // @return network: network as integer @@ -149,7 +142,7 @@ static int parse_cidr(const char *s, uint32_t *network, uint32_t *mask) prefix = (int)val; } else { - /* no CIDR suffix -> exact host match */ + // no CIDR suffix -> exact host match prefix = 32; } @@ -179,7 +172,6 @@ static int parse_cidr(const char *s, uint32_t *network, uint32_t *mask) return 0; } -// // name: free_ipprio_list // @param list: pointer to list to free // @return: void @@ -193,7 +185,6 @@ static void free_ipprio_list(struct ipprio_entry *list) } } -// // name: parse_ippriorities // @param args: full prio_args string // @return: 0 if ok -1 if not @@ -223,8 +214,7 @@ static struct ipprio_entry *parse_ippriorities(const char *args) int priority; struct ipprio_entry *e; - /* A single IP without CIDR mask and priority attain backward compatibility - */ + // A single IP without CIDR mask and priority attain backward compatibility colon = strrchr(entry, ':'); if (!colon) { @@ -237,7 +227,7 @@ static struct ipprio_entry *parse_ippriorities(const char *args) cidr = entry; priority = 20; - entry = NULL; /* consume the only entry */ + entry = NULL; // consume the only entry } else { *colon = '\0'; cidr = entry; @@ -291,7 +281,6 @@ static struct ipprio_entry *parse_ippriorities(const char *args) return ipprio_list; } -// // name: find_priority - lookup IP in list of CIDRs // @param ipstr: IP to lookup as a string // @param ipprio_list: list of CIDR blocks for the search @@ -367,7 +356,6 @@ static int find_priority(const char *sysname, const char *ipstr, return best_prio; } -// // name: inet_prio // @param // @return prio @@ -440,7 +428,6 @@ int iet_prio(struct udev_device *udev, char *args) return prio; } -// // Prioritizer entry point int getprio(struct path *pp, char *args) { -- 2.55.0
