From: Ondrej Zajicek Date: Thu, 11 Mar 2010 17:55:59 +0000 (+0100) Subject: Merge branch 'new' into socket2 X-Git-Tag: v1.2.2~17^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=54305181f6ee3af57dd3d15d53ea2e851b36ed23;p=thirdparty%2Fbird.git Merge branch 'new' into socket2 --- 54305181f6ee3af57dd3d15d53ea2e851b36ed23 diff --cc nest/config.Y index f9e88d591,5a8950512..792012e72 --- a/nest/config.Y +++ b/nest/config.Y @@@ -459,22 -459,21 +459,21 @@@ echo_size ; CF_CLI(DISABLE, proto_patt, | \"\" | all, [[Disable protocol]]) - { proto_xxable($2, XX_DISABLE); } ; + { proto_apply_cmd($2, proto_cmd_disable, 1, 0); } ; CF_CLI(ENABLE, proto_patt, | \"\" | all, [[Enable protocol]]) - { proto_xxable($2, XX_ENABLE); } ; + { proto_apply_cmd($2, proto_cmd_enable, 1, 0); } ; CF_CLI(RESTART, proto_patt, | \"\" | all, [[Restart protocol]]) - { proto_xxable($2, XX_RESTART); } ; + { proto_apply_cmd($2, proto_cmd_restart, 1, 0); } ; CF_CLI(RELOAD, proto_patt, | \"\" | all, [[Reload protocol]]) - { proto_xxable($2, XX_RELOAD); } ; + { proto_apply_cmd($2, proto_cmd_reload, 1, CMD_RELOAD); } ; CF_CLI(RELOAD IN, proto_patt, | \"\" | all, [[Reload protocol (just imported routes)]]) - { proto_xxable($3, XX_RELOAD_IN); } ; + { proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_IN); } ; CF_CLI(RELOAD OUT, proto_patt, | \"\" | all, [[Reload protocol (just exported routes)]]) - { proto_xxable($3, XX_RELOAD_OUT); } ; + { proto_apply_cmd($3, proto_cmd_reload, 1, CMD_RELOAD_OUT); } ; CF_CLI_HELP(DEBUG, ..., [[Control protocol debugging via BIRD logs]]) -CF_CLI(DEBUG, proto_patt debug_mask, ( | | all) (all | off | { states | routes | filters | events | packets }), [[Control protocol debugging via BIRD logs]]) +CF_CLI(DEBUG, proto_patt debug_mask, ( | | all) (all | off | { states | routes | filters | interfaces | events | packets }), [[Control protocol debugging via BIRD logs]]) - { proto_debug($2, 0, $3); } - ; + { proto_apply_cmd($2, proto_cmd_debug, 1, $3); } ; CF_CLI_HELP(MRTDUMP, ..., [[Control protocol debugging via MRTdump files]]) CF_CLI(MRTDUMP, proto_patt mrtdump_mask, ( | | all) (all | off | { states | messages }), [[Control protocol debugging via MRTdump format]]) diff --cc proto/ospf/hello.c index 9f174df81,2f3a8a81b..7fe82801d --- a/proto/ospf/hello.c +++ b/proto/ospf/hello.c @@@ -47,9 -47,9 +47,9 @@@ ospf_hello_receive(struct ospf_packet * { struct proto_ospf *po = ifa->oa->po; struct proto *p = &po->proto; - char *beg = "Bad OSPF HELLO packet from ", *rec = " received: "; + char *beg = "OSPF: Bad HELLO packet from "; - unsigned int size, i, twoway, oldpriority, eligible, peers; - u32 olddr, oldbdr, oldiface_id, tmp; + unsigned int size, i, twoway, eligible, peers; + u32 tmp; u32 *pnrid; size = ntohs(ps_i->length); diff --cc proto/ospf/packet.c index 6697057bd,ea5f7a861..95f7653c6 --- a/proto/ospf/packet.c +++ b/proto/ospf/packet.c @@@ -266,52 -264,21 +265,52 @@@ ospf_pkt_checkauth(struct ospf_neighbo * non generic functions. */ int -ospf_rx_hook(sock * sk, int size) +ospf_rx_hook(sock *sk, int size) { - struct ospf_packet *ps; - struct ospf_iface *ifa = (struct ospf_iface *) (sk->data); + char *mesg = "OSPF: Bad packet from "; + + /* We want just packets from sk->iface. Unfortunately, on BSD we + cannot filter out other packets at kernel level and we receive + all packets on all sockets */ + if (sk->lifindex != sk->iface->index) + return 1; + + DBG("OSPF: RX hook called (iface %s, src %I, dst %I)\n", + sk->iface->name, sk->faddr, sk->laddr); + + /* Initially, the packet is associated with the 'master' iface */ + struct ospf_iface *ifa = sk->data; struct proto_ospf *po = ifa->oa->po; -- struct proto *p = &po->proto; - struct ospf_neighbor *n; - int osize; - char *mesg = "Bad OSPF packet from "; - struct ospf_iface *iff; ++ // struct proto *p = &po->proto; + + int src_local = ifa_match_addr(ifa->addr, sk->faddr); + int dst_local = ipa_equal(sk->laddr, ifa->addr->ip); + int dst_mcast = ipa_equal(sk->laddr, AllSPFRouters) || ipa_equal(sk->laddr, AllDRouters); - if (ifa->stub) - return (1); +#ifdef OSPFv2 + /* First, we eliminate packets with strange address combinations. + * In OSPFv2, they might be for other ospf_ifaces (with different IP + * prefix) on the same real iface, so we don't log it. We enforce + * that (src_local || dst_local), therefore we are eliminating all + * such cases. + */ + if (dst_mcast && !src_local) + return 1; + if (!dst_mcast && !dst_local) + return 1; + +#else /* OSPFv3 */ + + /* In OSPFv3, src_local and dst_local mean link-local. + * RFC 5340 says that local (non-vlink) packets use + * link-local src address, but does not enforce it. Strange. + */ + if (dst_mcast && !src_local) + log(L_WARN "OSPF: Received multicast packet from %I (not link-local)", sk->faddr); +#endif - ps = (struct ospf_packet *) ip_skip_header(sk->rbuf, &size); + /* Second, we check packet size, checksum, and the protocol version */ + struct ospf_packet *ps = (struct ospf_packet *) ip_skip_header(sk->rbuf, &size); if (ps == NULL) { diff --cc proto/ospf/rt.c index 18dc3bbd6,c856eea1f..9a330a83d --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@@ -571,9 -569,9 +571,9 @@@ ospf_rt_sum_tr(struct ospf_area *oa metric = ls->metric & METRIC_MASK; options = 0; type = ORT_NET; - re = (ort *) fib_find(&po->rtf, &ip, pxlen); + re = fib_find(&po->rtf, &ip, pxlen); } - else if (en->lsa.type == LSA_T_SUM_RT) + else // en->lsa.type == LSA_T_SUM_RT { #ifdef OSPFv2 struct ospf_lsa_sum *ls = en->lsa_body;