/usr/src/openvswitch-1.4.0/tests/uuidfilt.pl is in openvswitch-datapath-dkms 1.4.0-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #! /usr/bin/perl
use strict;
use warnings;
our %uuids;
our $n_uuids = 0;
sub lookup_uuid {
my ($uuid) = @_;
if (!exists($uuids{$uuid})) {
$uuids{$uuid} = $n_uuids++;
}
return "<$uuids{$uuid}>";
}
sub sort_set {
my ($s) = @_;
my (@uuids) = sort { $a <=> $b } (grep(/\d+/, split(/(\d+)/, $s)));
return '["set",[' . join(',', map('["uuid","<' . $_ . '>"]', @uuids)) . ']]';
}
my $u = '[0-9a-fA-F]';
my $uuid_re = "${u}{8}-${u}{4}-${u}{4}-${u}{4}-${u}{12}";
while (<>) {
s/($uuid_re)/lookup_uuid($1)/eg;
# Sort sets like this:
# [["uuid","<1>"],["uuid","<0>"]]
# to look like this:
# [["uuid","<0>"],["uuid","<1>"]]
s/(\["set",\[(,?\["uuid","<\d+>"\])+\]\])/sort_set($1)/ge;
print $_;
}
|