···25252626 /* Try to fill in the third arg: dataoff is offset past network protocol2727 hdr. Return true if possible. */2828- int (*pkt_to_tuple)(const struct sk_buff *skb,2929- unsigned int dataoff,3030- struct nf_conntrack_tuple *tuple);2828+ bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int dataoff,2929+ struct nf_conntrack_tuple *tuple);31303231 /* Invert the per-proto part of the tuple: ie. turn xmit into reply.3332 * Some packets can't be inverted: return 0 in that case.3433 */3535- int (*invert_tuple)(struct nf_conntrack_tuple *inverse,3636- const struct nf_conntrack_tuple *orig);3434+ bool (*invert_tuple)(struct nf_conntrack_tuple *inverse,3535+ const struct nf_conntrack_tuple *orig);37363837 /* Returns verdict for packet, or -1 for invalid. */3938 int (*packet)(struct nf_conn *ct,···44454546 /* Called when a new connection for this protocol found;4647 * returns TRUE if it's OK. If so, packet() called next. */4747- int (*new)(struct nf_conn *ct, const struct sk_buff *skb,4848- unsigned int dataoff);4848+ bool (*new)(struct nf_conn *ct, const struct sk_buff *skb,4949+ unsigned int dataoff);49505051 /* Called when a conntrack entry is destroyed */5152 void (*destroy)(struct nf_conn *ct);
+12-13
net/ipv4/netfilter/nf_conntrack_proto_icmp.c
···22222323static unsigned long nf_ct_icmp_timeout __read_mostly = 30*HZ;24242525-static int icmp_pkt_to_tuple(const struct sk_buff *skb,2626- unsigned int dataoff,2727- struct nf_conntrack_tuple *tuple)2525+static bool icmp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,2626+ struct nf_conntrack_tuple *tuple)2827{2928 const struct icmphdr *hp;3029 struct icmphdr _hdr;31303231 hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);3332 if (hp == NULL)3434- return 0;3333+ return false;35343635 tuple->dst.u.icmp.type = hp->type;3736 tuple->src.u.icmp.id = hp->un.echo.id;3837 tuple->dst.u.icmp.code = hp->code;39384040- return 1;3939+ return true;4140}42414342/* Add 1; spaces filled with 0. */···5152 [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 15253};53545454-static int icmp_invert_tuple(struct nf_conntrack_tuple *tuple,5555- const struct nf_conntrack_tuple *orig)5555+static bool icmp_invert_tuple(struct nf_conntrack_tuple *tuple,5656+ const struct nf_conntrack_tuple *orig)5657{5758 if (orig->dst.u.icmp.type >= sizeof(invmap)5859 || !invmap[orig->dst.u.icmp.type])5959- return 0;6060+ return false;60616162 tuple->src.u.icmp.id = orig->src.u.icmp.id;6263 tuple->dst.u.icmp.type = invmap[orig->dst.u.icmp.type] - 1;6364 tuple->dst.u.icmp.code = orig->dst.u.icmp.code;6464- return 1;6565+ return true;6566}66676768/* Print out the per-protocol part of the tuple. */···100101}101102102103/* Called when a new connection for this protocol found. */103103-static int icmp_new(struct nf_conn *ct,104104- const struct sk_buff *skb, unsigned int dataoff)104104+static bool icmp_new(struct nf_conn *ct, const struct sk_buff *skb,105105+ unsigned int dataoff)105106{106107 static const u_int8_t valid_new[] = {107108 [ICMP_ECHO] = 1,···116117 pr_debug("icmp: can't create new conn with type %u\n",117118 ct->tuplehash[0].tuple.dst.u.icmp.type);118119 NF_CT_DUMP_TUPLE(&ct->tuplehash[0].tuple);119119- return 0;120120+ return false;120121 }121122 atomic_set(&ct->proto.icmp.count, 0);122122- return 1;123123+ return true;123124}124125125126/* Returns conntrack if it dealt with ICMP, and filled in skb fields */
+13-14
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
···28282929static unsigned long nf_ct_icmpv6_timeout __read_mostly = 30*HZ;30303131-static int icmpv6_pkt_to_tuple(const struct sk_buff *skb,3232- unsigned int dataoff,3333- struct nf_conntrack_tuple *tuple)3131+static bool icmpv6_pkt_to_tuple(const struct sk_buff *skb,3232+ unsigned int dataoff,3333+ struct nf_conntrack_tuple *tuple)3434{3535 const struct icmp6hdr *hp;3636 struct icmp6hdr _hdr;37373838 hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);3939 if (hp == NULL)4040- return 0;4040+ return false;4141 tuple->dst.u.icmp.type = hp->icmp6_type;4242 tuple->src.u.icmp.id = hp->icmp6_identifier;4343 tuple->dst.u.icmp.code = hp->icmp6_code;44444545- return 1;4545+ return true;4646}47474848/* Add 1; spaces filled with 0. */···5353 [ICMPV6_NI_REPLY - 128] = ICMPV6_NI_REPLY +15454};55555656-static int icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,5757- const struct nf_conntrack_tuple *orig)5656+static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,5757+ const struct nf_conntrack_tuple *orig)5858{5959 int type = orig->dst.u.icmp.type - 128;6060 if (type < 0 || type >= sizeof(invmap) || !invmap[type])6161- return 0;6161+ return false;62626363 tuple->src.u.icmp.id = orig->src.u.icmp.id;6464 tuple->dst.u.icmp.type = invmap[type] - 1;6565 tuple->dst.u.icmp.code = orig->dst.u.icmp.code;6666- return 1;6666+ return true;6767}68686969/* Print out the per-protocol part of the tuple. */···102102}103103104104/* Called when a new connection for this protocol found. */105105-static int icmpv6_new(struct nf_conn *ct,106106- const struct sk_buff *skb,107107- unsigned int dataoff)105105+static bool icmpv6_new(struct nf_conn *ct, const struct sk_buff *skb,106106+ unsigned int dataoff)108107{109108 static const u_int8_t valid_new[] = {110109 [ICMPV6_ECHO_REQUEST - 128] = 1,···116117 pr_debug("icmpv6: can't create new conn with type %u\n",117118 type + 128);118119 NF_CT_DUMP_TUPLE(&ct->tuplehash[0].tuple);119119- return 0;120120+ return false;120121 }121122 atomic_set(&ct->proto.icmp.count, 0);122122- return 1;123123+ return true;123124}124125125126static int
···14141515static unsigned int nf_ct_generic_timeout __read_mostly = 600*HZ;16161717-static int generic_pkt_to_tuple(const struct sk_buff *skb,1818- unsigned int dataoff,1919- struct nf_conntrack_tuple *tuple)1717+static bool generic_pkt_to_tuple(const struct sk_buff *skb,1818+ unsigned int dataoff,1919+ struct nf_conntrack_tuple *tuple)2020{2121 tuple->src.u.all = 0;2222 tuple->dst.u.all = 0;23232424- return 1;2424+ return true;2525}26262727-static int generic_invert_tuple(struct nf_conntrack_tuple *tuple,2828- const struct nf_conntrack_tuple *orig)2727+static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,2828+ const struct nf_conntrack_tuple *orig)2929{3030 tuple->src.u.all = 0;3131 tuple->dst.u.all = 0;32323333- return 1;3333+ return true;3434}35353636/* Print out the per-protocol part of the tuple. */···5353}54545555/* Called when a new connection for this protocol found. */5656-static int new(struct nf_conn *ct, const struct sk_buff *skb,5757- unsigned int dataoff)5656+static bool new(struct nf_conn *ct, const struct sk_buff *skb,5757+ unsigned int dataoff)5858{5959- return 1;5959+ return true;6060}61616262#ifdef CONFIG_SYSCTL
+12-13
net/netfilter/nf_conntrack_proto_gre.c
···148148/* PUBLIC CONNTRACK PROTO HELPER FUNCTIONS */149149150150/* invert gre part of tuple */151151-static int gre_invert_tuple(struct nf_conntrack_tuple *tuple,152152- const struct nf_conntrack_tuple *orig)151151+static bool gre_invert_tuple(struct nf_conntrack_tuple *tuple,152152+ const struct nf_conntrack_tuple *orig)153153{154154 tuple->dst.u.gre.key = orig->src.u.gre.key;155155 tuple->src.u.gre.key = orig->dst.u.gre.key;156156- return 1;156156+ return true;157157}158158159159/* gre hdr info to tuple */160160-static int gre_pkt_to_tuple(const struct sk_buff *skb,161161- unsigned int dataoff,162162- struct nf_conntrack_tuple *tuple)160160+static bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,161161+ struct nf_conntrack_tuple *tuple)163162{164163 const struct gre_hdr_pptp *pgrehdr;165164 struct gre_hdr_pptp _pgrehdr;···172173 /* try to behave like "nf_conntrack_proto_generic" */173174 tuple->src.u.all = 0;174175 tuple->dst.u.all = 0;175175- return 1;176176+ return true;176177 }177178178179 /* PPTP header is variable length, only need up to the call_id field */179180 pgrehdr = skb_header_pointer(skb, dataoff, 8, &_pgrehdr);180181 if (!pgrehdr)181181- return 1;182182+ return true;182183183184 if (ntohs(grehdr->protocol) != GRE_PROTOCOL_PPTP) {184185 pr_debug("GRE_VERSION_PPTP but unknown proto\n");185185- return 0;186186+ return false;186187 }187188188189 tuple->dst.u.gre.key = pgrehdr->call_id;189190 srckey = gre_keymap_lookup(tuple);190191 tuple->src.u.gre.key = srckey;191192192192- return 1;193193+ return true;193194}194195195196/* print gre part of tuple */···234235}235236236237/* Called when a new connection for this protocol found. */237237-static int gre_new(struct nf_conn *ct, const struct sk_buff *skb,238238- unsigned int dataoff)238238+static bool gre_new(struct nf_conn *ct, const struct sk_buff *skb,239239+ unsigned int dataoff)239240{240241 pr_debug(": ");241242 NF_CT_DUMP_TUPLE(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);···245246 ct->proto.gre.stream_timeout = GRE_STREAM_TIMEOUT;246247 ct->proto.gre.timeout = GRE_TIMEOUT;247248248248- return 1;249249+ return true;249250}250251251252/* Called when a conntrack entry has already been removed from the hashes
+16-17
net/netfilter/nf_conntrack_proto_sctp.c
···130130 }131131};132132133133-static int sctp_pkt_to_tuple(const struct sk_buff *skb,134134- unsigned int dataoff,135135- struct nf_conntrack_tuple *tuple)133133+static bool sctp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,134134+ struct nf_conntrack_tuple *tuple)136135{137136 sctp_sctphdr_t _hdr, *hp;138137139138 /* Actually only need first 8 bytes. */140139 hp = skb_header_pointer(skb, dataoff, 8, &_hdr);141140 if (hp == NULL)142142- return 0;141141+ return false;143142144143 tuple->src.u.sctp.port = hp->source;145144 tuple->dst.u.sctp.port = hp->dest;146146- return 1;145145+ return true;147146}148147149149-static int sctp_invert_tuple(struct nf_conntrack_tuple *tuple,150150- const struct nf_conntrack_tuple *orig)148148+static bool sctp_invert_tuple(struct nf_conntrack_tuple *tuple,149149+ const struct nf_conntrack_tuple *orig)151150{152151 tuple->src.u.sctp.port = orig->dst.u.sctp.port;153152 tuple->dst.u.sctp.port = orig->src.u.sctp.port;154154- return 1;153153+ return true;155154}156155157156/* Print out the per-protocol part of the tuple. */···389390}390391391392/* Called when a new connection for this protocol found. */392392-static int sctp_new(struct nf_conn *ct, const struct sk_buff *skb,393393- unsigned int dataoff)393393+static bool sctp_new(struct nf_conn *ct, const struct sk_buff *skb,394394+ unsigned int dataoff)394395{395396 enum sctp_conntrack new_state;396397 sctp_sctphdr_t _sctph, *sh;···400401401402 sh = skb_header_pointer(skb, dataoff, sizeof(_sctph), &_sctph);402403 if (sh == NULL)403403- return 0;404404+ return false;404405405406 if (do_basic_checks(ct, skb, dataoff, map) != 0)406406- return 0;407407+ return false;407408408409 /* If an OOTB packet has any of these chunks discard (Sec 8.4) */409410 if (test_bit(SCTP_CID_ABORT, map) ||410411 test_bit(SCTP_CID_SHUTDOWN_COMPLETE, map) ||411412 test_bit(SCTP_CID_COOKIE_ACK, map))412412- return 0;413413+ return false;413414414415 new_state = SCTP_CONNTRACK_MAX;415416 for_each_sctp_chunk (skb, sch, _sch, offset, dataoff, count) {···421422 if (new_state == SCTP_CONNTRACK_NONE ||422423 new_state == SCTP_CONNTRACK_MAX) {423424 pr_debug("nf_conntrack_sctp: invalid new deleting.\n");424424- return 0;425425+ return false;425426 }426427427428 /* Copy the vtag into the state info */···432433 ih = skb_header_pointer(skb, offset + sizeof(sctp_chunkhdr_t),433434 sizeof(_inithdr), &_inithdr);434435 if (ih == NULL)435435- return 0;436436+ return false;436437437438 pr_debug("Setting vtag %x for new conn\n",438439 ih->init_tag);···441442 ih->init_tag;442443 } else {443444 /* Sec 8.5.1 (A) */444444- return 0;445445+ return false;445446 }446447 }447448 /* If it is a shutdown ack OOTB packet, we expect a return···455456 ct->proto.sctp.state = new_state;456457 }457458458458- return 1;459459+ return true;459460}460461461462#ifdef CONFIG_SYSCTL
+25-27
net/netfilter/nf_conntrack_proto_tcp.c
···257257 }258258};259259260260-static int tcp_pkt_to_tuple(const struct sk_buff *skb,261261- unsigned int dataoff,262262- struct nf_conntrack_tuple *tuple)260260+static bool tcp_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,261261+ struct nf_conntrack_tuple *tuple)263262{264263 const struct tcphdr *hp;265264 struct tcphdr _hdr;···266267 /* Actually only need first 8 bytes. */267268 hp = skb_header_pointer(skb, dataoff, 8, &_hdr);268269 if (hp == NULL)269269- return 0;270270+ return false;270271271272 tuple->src.u.tcp.port = hp->source;272273 tuple->dst.u.tcp.port = hp->dest;273274274274- return 1;275275+ return true;275276}276277277277-static int tcp_invert_tuple(struct nf_conntrack_tuple *tuple,278278- const struct nf_conntrack_tuple *orig)278278+static bool tcp_invert_tuple(struct nf_conntrack_tuple *tuple,279279+ const struct nf_conntrack_tuple *orig)279280{280281 tuple->src.u.tcp.port = orig->dst.u.tcp.port;281282 tuple->dst.u.tcp.port = orig->src.u.tcp.port;282282- return 1;283283+ return true;283284}284285285286/* Print out the per-protocol part of the tuple. */···477478 }478479}479480480480-static int tcp_in_window(const struct nf_conn *ct,481481- struct ip_ct_tcp *state,482482- enum ip_conntrack_dir dir,483483- unsigned int index,484484- const struct sk_buff *skb,485485- unsigned int dataoff,486486- const struct tcphdr *tcph,487487- int pf)481481+static bool tcp_in_window(const struct nf_conn *ct,482482+ struct ip_ct_tcp *state,483483+ enum ip_conntrack_dir dir,484484+ unsigned int index,485485+ const struct sk_buff *skb,486486+ unsigned int dataoff,487487+ const struct tcphdr *tcph,488488+ int pf)488489{489490 struct ip_ct_tcp_state *sender = &state->seen[dir];490491 struct ip_ct_tcp_state *receiver = &state->seen[!dir];491492 const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;492493 __u32 seq, ack, sack, end, win, swin;493493- int res;494494+ bool res;494495495496 /*496497 * Get the required data from the packet.···656657 state->retrans = 0;657658 }658659 }659659- res = 1;660660+ res = true;660661 } else {661661- res = 0;662662+ res = false;662663 if (sender->flags & IP_CT_TCP_FLAG_BE_LIBERAL ||663664 nf_ct_tcp_be_liberal)664664- res = 1;665665+ res = true;665666 if (!res && LOG_INVALID(IPPROTO_TCP))666667 nf_log_packet(pf, 0, skb, NULL, NULL, NULL,667668 "nf_ct_tcp: %s ",···675676 : "SEQ is over the upper bound (over the window of the receiver)");676677 }677678678678- pr_debug("tcp_in_window: res=%i sender end=%u maxend=%u maxwin=%u "679679+ pr_debug("tcp_in_window: res=%u sender end=%u maxend=%u maxwin=%u "679680 "receiver end=%u maxend=%u maxwin=%u\n",680681 res, sender->td_end, sender->td_maxend, sender->td_maxwin,681682 receiver->td_end, receiver->td_maxend, receiver->td_maxwin);···981982}982983983984/* Called when a new connection for this protocol found. */984984-static int tcp_new(struct nf_conn *ct,985985- const struct sk_buff *skb,986986- unsigned int dataoff)985985+static bool tcp_new(struct nf_conn *ct, const struct sk_buff *skb,986986+ unsigned int dataoff)987987{988988 enum tcp_conntrack new_state;989989 const struct tcphdr *th;···10011003 /* Invalid: delete conntrack */10021004 if (new_state >= TCP_CONNTRACK_MAX) {10031005 pr_debug("nf_ct_tcp: invalid new deleting.\n");10041004- return 0;10061006+ return false;10051007 }1006100810071009 if (new_state == TCP_CONNTRACK_SYN_SENT) {···10191021 ct->proto.tcp.seen[1].flags = 0;10201022 } else if (nf_ct_tcp_loose == 0) {10211023 /* Don't try to pick up connections. */10221022- return 0;10241024+ return false;10231025 } else {10241026 /*10251027 * We are in the middle of a connection,···10591061 sender->td_scale,10601062 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,10611063 receiver->td_scale);10621062- return 1;10641064+ return true;10631065}1064106610651067#if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
+9-9
net/netfilter/nf_conntrack_proto_udp.c
···2626static unsigned int nf_ct_udp_timeout __read_mostly = 30*HZ;2727static unsigned int nf_ct_udp_timeout_stream __read_mostly = 180*HZ;28282929-static int udp_pkt_to_tuple(const struct sk_buff *skb,2929+static bool udp_pkt_to_tuple(const struct sk_buff *skb,3030 unsigned int dataoff,3131 struct nf_conntrack_tuple *tuple)3232{···3636 /* Actually only need first 8 bytes. */3737 hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);3838 if (hp == NULL)3939- return 0;3939+ return false;40404141 tuple->src.u.udp.port = hp->source;4242 tuple->dst.u.udp.port = hp->dest;43434444- return 1;4444+ return true;4545}46464747-static int udp_invert_tuple(struct nf_conntrack_tuple *tuple,4848- const struct nf_conntrack_tuple *orig)4747+static bool udp_invert_tuple(struct nf_conntrack_tuple *tuple,4848+ const struct nf_conntrack_tuple *orig)4949{5050 tuple->src.u.udp.port = orig->dst.u.udp.port;5151 tuple->dst.u.udp.port = orig->src.u.udp.port;5252- return 1;5252+ return true;5353}54545555/* Print out the per-protocol part of the tuple. */···8383}84848585/* Called when a new connection for this protocol found. */8686-static int udp_new(struct nf_conn *ct, const struct sk_buff *skb,8787- unsigned int dataoff)8686+static bool udp_new(struct nf_conn *ct, const struct sk_buff *skb,8787+ unsigned int dataoff)8888{8989- return 1;8989+ return true;9090}91919292static int udp_error(struct sk_buff *skb, unsigned int dataoff,
+11-11
net/netfilter/nf_conntrack_proto_udplite.c
···2727static unsigned int nf_ct_udplite_timeout __read_mostly = 30*HZ;2828static unsigned int nf_ct_udplite_timeout_stream __read_mostly = 180*HZ;29293030-static int udplite_pkt_to_tuple(const struct sk_buff *skb,3131- unsigned int dataoff,3232- struct nf_conntrack_tuple *tuple)3030+static bool udplite_pkt_to_tuple(const struct sk_buff *skb,3131+ unsigned int dataoff,3232+ struct nf_conntrack_tuple *tuple)3333{3434 const struct udphdr *hp;3535 struct udphdr _hdr;36363737 hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr);3838 if (hp == NULL)3939- return 0;3939+ return false;40404141 tuple->src.u.udp.port = hp->source;4242 tuple->dst.u.udp.port = hp->dest;4343- return 1;4343+ return true;4444}45454646-static int udplite_invert_tuple(struct nf_conntrack_tuple *tuple,4747- const struct nf_conntrack_tuple *orig)4646+static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple,4747+ const struct nf_conntrack_tuple *orig)4848{4949 tuple->src.u.udp.port = orig->dst.u.udp.port;5050 tuple->dst.u.udp.port = orig->src.u.udp.port;5151- return 1;5151+ return true;5252}53535454/* Print out the per-protocol part of the tuple. */···8383}84848585/* Called when a new connection for this protocol found. */8686-static int udplite_new(struct nf_conn *ct, const struct sk_buff *skb,8787- unsigned int dataoff)8686+static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb,8787+ unsigned int dataoff)8888{8989- return 1;8989+ return true;9090}91919292static int udplite_error(struct sk_buff *skb, unsigned int dataoff,