diff --git a/ip/ipmroute.c b/ip/ipmroute.c index 125a13f8..fffa9e2c 100644 --- a/ip/ipmroute.c +++ b/ip/ipmroute.c @@ -97,15 +97,25 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) if (filter.af && filter.af != r->rtm_family) return 0; - if (tb[RTA_DST] && - filter.mdst.bitlen > 0 && - inet_addr_match(RTA_DATA(tb[RTA_DST]), &filter.mdst, filter.mdst.bitlen)) - return 0; + if (tb[RTA_DST] && filter.mdst.bitlen > 0) { + inet_prefix dst; - if (tb[RTA_SRC] && - filter.msrc.bitlen > 0 && - inet_addr_match(RTA_DATA(tb[RTA_SRC]), &filter.msrc, filter.msrc.bitlen)) - return 0; + memset(&dst, 0, sizeof(dst)); + dst.family = r->rtm_family; + memcpy(&dst.data, RTA_DATA(tb[RTA_DST]), RTA_PAYLOAD(tb[RTA_DST])); + if (inet_addr_match(&dst, &filter.mdst, filter.mdst.bitlen)) + return 0; + } + + if (tb[RTA_SRC] && filter.msrc.bitlen > 0) { + inet_prefix src; + + memset(&src, 0, sizeof(src)); + src.family = r->rtm_family; + memcpy(&src.data, RTA_DATA(tb[RTA_SRC]), RTA_PAYLOAD(tb[RTA_SRC])); + if (inet_addr_match(&src, &filter.msrc, filter.msrc.bitlen)) + return 0; + } family = r->rtm_family == RTNL_FAMILY_IPMR ? AF_INET : AF_INET6; diff --git a/ip/iptunnel.c b/ip/iptunnel.c index be84b83e..78fa9885 100644 --- a/ip/iptunnel.c +++ b/ip/iptunnel.c @@ -167,10 +167,14 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p) NEXT_ARG(); if (strcmp(*argv, "any")) p->iph.daddr = get_addr32(*argv); + else + p->iph.daddr = htonl(INADDR_ANY); } else if (strcmp(*argv, "local") == 0) { NEXT_ARG(); if (strcmp(*argv, "any")) p->iph.saddr = get_addr32(*argv); + else + p->iph.saddr = htonl(INADDR_ANY); } else if (strcmp(*argv, "dev") == 0) { NEXT_ARG(); strncpy(medium, *argv, IFNAMSIZ-1); diff --git a/misc/ss.c b/misc/ss.c index aedf10f8..78dfd564 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -1085,7 +1085,7 @@ static int run_ssfilter(struct ssfilter *f, struct sockstat *s) strspn(p+1, "0123456789abcdef") == 5); } if (s->local.family == AF_PACKET) - return s->lport == 0 && s->local.data == 0; + return s->lport == 0 && s->local.data[0] == 0; if (s->local.family == AF_NETLINK) return s->lport < 0; diff --git a/tc/m_pedit.c b/tc/m_pedit.c index dfe9b2eb..4fdd189d 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -160,17 +160,9 @@ pack_key32(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) int pack_key16(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) { - int ind = 0, stride = 0; + int ind, stride; __u32 m[4] = {0xFFFF0000,0xFF0000FF,0x0000FFFF}; - if (0 > tkey->off) { - ind = tkey->off + 1; - if (0 > ind) - ind = -1*ind; - } else { - ind = tkey->off; - } - if (tkey->val > 0xFFFF || tkey->mask > 0xFFFF) { fprintf(stderr, "pack_key16 bad value\n"); return -1; @@ -178,18 +170,16 @@ pack_key16(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) ind = tkey->off & 3; - if (0 > ind || 2 < ind) { + if (ind == 3) { fprintf(stderr, "pack_key16 bad index value %d\n",ind); return -1; } stride = 8 * ind; tkey->val = htons(tkey->val); - if (stride > 0) { - tkey->val <<= stride; - tkey->mask <<= stride; - retain <<= stride; - } + tkey->val <<= stride; + tkey->mask <<= stride; + retain <<= stride; tkey->mask = retain|m[ind]; tkey->off &= ~3; @@ -203,28 +193,22 @@ pack_key16(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) int pack_key8(__u32 retain,struct tc_pedit_sel *sel,struct tc_pedit_key *tkey) { - int ind = 0, stride = 0; + int ind, stride; __u32 m[4] = {0xFFFFFF00,0xFFFF00FF,0xFF00FFFF,0x00FFFFFF}; - if (0 > tkey->off) { - ind = tkey->off + 1; - if (0 > ind) - ind = -1*ind; - } else { - ind = tkey->off; - } - if (tkey->val > 0xFF || tkey->mask > 0xFF) { fprintf(stderr, "pack_key8 bad value (val %x mask %x\n", tkey->val, tkey->mask); return -1; } ind = tkey->off & 3; + stride = 8 * ind; tkey->val <<= stride; tkey->mask <<= stride; retain <<= stride; tkey->mask = retain|m[ind]; + tkey->off &= ~3; if (pedit_debug)