pgcmp() is using a simple xor algorithm for hashing. Main intention
here is to have a quick comparison if two paths are identical.
However, this algorithm is prone to hash collisions, so even if
two hashes match we should still check the individual paths to
avoid collisions.
Signed-off-by: Hannes Reinecke <hare@suse.de>
compute_pgid(pgp);
vector_foreach_slot (cmpp->pg, cpgp, j) {
- if (pgp->id == cpgp->id) {
+ if (pgp->id == cpgp->id &&
+ !pathcmp(pgp, cpgp)) {
r = 0;
break;
}
return count;
}
+extern int
+pathcmp (struct pathgroup *pgp, struct pathgroup *cpgp)
+{
+ int i, j;
+ struct path *pp, *cpp;
+ int pnum = 0, found = 0;
+
+ vector_foreach_slot(pgp->paths, pp, i) {
+ pnum++;
+ vector_foreach_slot(cpgp->paths, cpp, j) {
+ if ((long)pp == (long)cpp) {
+ found++;
+ break;
+ }
+ }
+ }
+
+ return pnum - found;
+}
+
struct path *
first_path (struct multipath * mpp)
{
int pathcountgr (struct pathgroup *, int);
int pathcount (struct multipath *, int);
+int pathcmp (struct pathgroup *, struct pathgroup *);
void setup_feature(struct multipath *, char *);
extern char sysfs_path[PATH_SIZE];