aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2017-01-06 06:50:45 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-01-06 06:50:45 +0000
commit705d145399cc090d19356b14eaa4543509ca6b5e (patch)
tree9f9e399f955bc51d523a875451114dc15c279978
parent31a12c7e1c3d6f7c792d61b9445be62490429a0d (diff)
parent1b32ccb0313537bd0bebcb6ec3c0398e90aa103a (diff)
downloadiproute2-oreo-dev.tar.gz
Merge "Update UID routing to upstream implementation." am: b072143d78 am: e3d477a8ad am: e6ccd07bf0android-wear-o-preview-4android-wear-o-preview-3android-wear-8.0.0_r2android-wear-8.0.0_r1android-vts-8.0_r9android-vts-8.0_r8android-vts-8.0_r7android-vts-8.0_r6android-vts-8.0_r2android-vts-8.0_r13android-vts-8.0_r12android-vts-8.0_r11android-vts-8.0_r10android-vts-8.0_r1android-security-8.0.0_r54android-security-8.0.0_r53android-security-8.0.0_r52android-o-preview-4android-o-preview-3android-o-preview-2android-o-preview-1android-o-iot-preview-5android-cts-8.0_r9android-cts-8.0_r8android-cts-8.0_r7android-cts-8.0_r6android-cts-8.0_r5android-cts-8.0_r4android-cts-8.0_r3android-cts-8.0_r26android-cts-8.0_r25android-cts-8.0_r24android-cts-8.0_r23android-cts-8.0_r22android-cts-8.0_r21android-cts-8.0_r20android-cts-8.0_r2android-cts-8.0_r19android-cts-8.0_r18android-cts-8.0_r17android-cts-8.0_r16android-cts-8.0_r15android-cts-8.0_r14android-cts-8.0_r13android-cts-8.0_r12android-cts-8.0_r11android-cts-8.0_r10android-cts-8.0_r1android-8.0.0_r9android-8.0.0_r7android-8.0.0_r51android-8.0.0_r50android-8.0.0_r49android-8.0.0_r48android-8.0.0_r47android-8.0.0_r46android-8.0.0_r45android-8.0.0_r44android-8.0.0_r43android-8.0.0_r42android-8.0.0_r41android-8.0.0_r40android-8.0.0_r4android-8.0.0_r39android-8.0.0_r38android-8.0.0_r37android-8.0.0_r36android-8.0.0_r35android-8.0.0_r34android-8.0.0_r33android-8.0.0_r32android-8.0.0_r31android-8.0.0_r30android-8.0.0_r3android-8.0.0_r29android-8.0.0_r28android-8.0.0_r27android-8.0.0_r26android-8.0.0_r25android-8.0.0_r24android-8.0.0_r23android-8.0.0_r22android-8.0.0_r21android-8.0.0_r2android-8.0.0_r17android-8.0.0_r16android-8.0.0_r15android-8.0.0_r13android-8.0.0_r12android-8.0.0_r11android-8.0.0_r10android-8.0.0_r1security-oc-releaseoreo-vts-releaseoreo-security-releaseoreo-releaseoreo-r6-releaseoreo-r5-releaseoreo-r4-releaseoreo-r3-releaseoreo-r2-releaseoreo-dr3-releaseoreo-dr2-releaseoreo-dr1-releaseoreo-dr1-devoreo-devoreo-cts-releaseo-preview-4o-preview-3o-preview-2o-previewo-iot-preview-5
am: 1b32ccb031 Change-Id: Id0ab6bdb6ae2bd0ac3fd3fa569280c1de524bf50
-rw-r--r--include/linux/fib_rules.h10
-rw-r--r--include/linux/rtnetlink.h5
-rw-r--r--ip/iproute.c19
-rw-r--r--ip/iprule.c28
4 files changed, 33 insertions, 29 deletions
diff --git a/include/linux/fib_rules.h b/include/linux/fib_rules.h
index 6dcde64c..bbf02a63 100644
--- a/include/linux/fib_rules.h
+++ b/include/linux/fib_rules.h
@@ -29,6 +29,11 @@ struct fib_rule_hdr {
__u32 flags;
};
+struct fib_rule_uid_range {
+ __u32 start;
+ __u32 end;
+};
+
enum {
FRA_UNSPEC,
FRA_DST, /* destination address */
@@ -49,8 +54,9 @@ enum {
FRA_TABLE, /* Extended table id */
FRA_FWMASK, /* mask for netfilter mark */
FRA_OIFNAME,
- FRA_UID_START,
- FRA_UID_END,
+ FRA_PAD,
+ FRA_L3MDEV, /* iif or oif is l3mdev goto its table */
+ FRA_UID_RANGE, /* UID range */
__FRA_MAX
};
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index dad2e8e0..5fc93371 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -305,14 +305,15 @@ enum rtattr_type_t {
RTA_MP_ALGO, /* no longer used */
RTA_TABLE,
RTA_MARK,
- RTA_MFC_STATS, /* not used - backported from the future */
- RTA_UID,
+ RTA_MFC_STATS,
RTA_VIA,
RTA_NEWDST,
RTA_PREF,
RTA_ENCAP_TYPE,
RTA_ENCAP,
RTA_EXPIRES,
+ RTA_PAD,
+ RTA_UID,
__RTA_MAX
};
diff --git a/ip/iproute.c b/ip/iproute.c
index 381c3ddc..7f81145e 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -474,9 +474,6 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
}
}
- if (tb[RTA_UID])
- fprintf(fp, " uid %u ", rta_getattr_u32(tb[RTA_UID]));
-
if (tb[RTA_FLOW] && filter.realmmask != ~0U) {
__u32 to = rta_getattr_u32(tb[RTA_FLOW]);
__u32 from = to>>16;
@@ -489,6 +486,10 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, "%s ",
rtnl_rtrealm_n2a(to, b1, sizeof(b1)));
}
+
+ if (tb[RTA_UID])
+ fprintf(fp, "uid %u ", rta_getattr_u32(tb[RTA_UID]));
+
if ((r->rtm_flags&RTM_F_CLONED) && r->rtm_family == AF_INET) {
__u32 flags = r->rtm_flags&~0xFFFF;
int first = 1;
@@ -1633,15 +1634,17 @@ static int iproute_get(int argc, char **argv)
strcmp(*argv, "dev") == 0) {
NEXT_ARG();
odev = *argv;
- } else if (matches(*argv, "uid") == 0) {
- uid_t uid;
- NEXT_ARG();
- get_unsigned(&uid, *argv, 0);
- addattr32(&req.n, sizeof(req), RTA_UID, uid);
} else if (matches(*argv, "notify") == 0) {
req.r.rtm_flags |= RTM_F_NOTIFY;
} else if (matches(*argv, "connected") == 0) {
connected = 1;
+ } else if (matches(*argv, "uid") == 0) {
+ uid_t uid;
+
+ NEXT_ARG();
+ if (get_unsigned(&uid, *argv, 0))
+ invarg("invalid UID\n", *argv);
+ addattr32(&req.n, sizeof(req), RTA_UID, uid);
} else {
inet_prefix addr;
if (strcmp(*argv, "to") == 0) {
diff --git a/ip/iprule.c b/ip/iprule.c
index c363cccf..ac835ab8 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -149,17 +149,10 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
fprintf(fp, "[detached] ");
}
- if (tb[FRA_UID_START] || tb[FRA_UID_END]) {
- fprintf(fp, "uidrange ");
- if (tb[FRA_UID_START])
- fprintf(fp, "%u", rta_getattr_u32(tb[FRA_UID_START]));
- else
- fprintf(fp, "???");
+ if (tb[FRA_UID_RANGE]) {
+ struct fib_rule_uid_range *r = RTA_DATA(tb[FRA_UID_RANGE]);
- if (tb[FRA_UID_END])
- fprintf(fp, "-%u ", rta_getattr_u32(tb[FRA_UID_END]));
- else
- fprintf(fp, "-??? ");
+ fprintf(fp, "uidrange %u-%u ", r->start, r->end);
}
table = rtm_get_table(r, tb);
@@ -441,19 +434,20 @@ static int iprule_modify(int cmd, int argc, char **argv)
} else if (strcmp(*argv, "oif") == 0) {
NEXT_ARG();
addattr_l(&req.n, sizeof(req), FRA_OIFNAME, *argv, strlen(*argv)+1);
+ } else if (strcmp(*argv, "uidrange") == 0) {
+ struct fib_rule_uid_range r;
+
+ NEXT_ARG();
+ if (sscanf(*argv, "%u-%u", &r.start, &r.end) != 2)
+ invarg("invalid UID range\n", *argv);
+ addattr_l(&req.n, sizeof(req), FRA_UID_RANGE, &r,
+ sizeof(r));
} else if (strcmp(*argv, "nat") == 0 ||
matches(*argv, "map-to") == 0) {
NEXT_ARG();
fprintf(stderr, "Warning: route NAT is deprecated\n");
addattr32(&req.n, sizeof(req), RTA_GATEWAY, get_addr32(*argv));
req.r.rtm_type = RTN_NAT;
- } else if (strcmp(*argv, "uidrange") == 0) {
- __u32 uid_start, uid_end;
- NEXT_ARG();
- if (sscanf(*argv, "%u-%u", &uid_start, &uid_end) != 2)
- invarg("UID range is invalid\n", *argv);
- addattr32(&req.n, sizeof(req), FRA_UID_START, uid_start);
- addattr32(&req.n, sizeof(req), FRA_UID_END, uid_end);
} else {
int type;