mirror of
				https://git.proxmox.com/git/mirror_frr
				synced 2025-11-04 13:43:22 +00:00 
			
		
		
		
	isisd: Fixed the way isis reads from bpf
With this fix, we parse the bpf to process every packet read Signed-off-by: Ali Rezaee nlndipi@hotmail.com
This commit is contained in:
		
							parent
							
								
									548dac0946
								
							
						
					
					
						commit
						b9347997d6
					
				@ -216,7 +216,8 @@ end:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int isis_recv_pdu_bcast(struct isis_circuit *circuit, u_char *ssnpa)
 | 
					int isis_recv_pdu_bcast(struct isis_circuit *circuit, u_char *ssnpa)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int bytesread = 0, bytestoread, offset, one = 1;
 | 
						int bytesread = 0, bytestoread, offset, one = 1, err = ISIS_OK;
 | 
				
			||||||
 | 
						u_char *buff_ptr;
 | 
				
			||||||
	struct bpf_hdr *bpf_hdr;
 | 
						struct bpf_hdr *bpf_hdr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	assert(circuit->fd > 0);
 | 
						assert(circuit->fd > 0);
 | 
				
			||||||
@ -237,18 +238,26 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, u_char *ssnpa)
 | 
				
			|||||||
	if (bytesread == 0)
 | 
						if (bytesread == 0)
 | 
				
			||||||
		return ISIS_WARNING;
 | 
							return ISIS_WARNING;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bpf_hdr = (struct bpf_hdr *)readbuff;
 | 
						buff_ptr = readbuff;
 | 
				
			||||||
 | 
						while (buff_ptr < readbuff + bytesread) {
 | 
				
			||||||
 | 
							bpf_hdr = (struct bpf_hdr *) buff_ptr;
 | 
				
			||||||
		assert(bpf_hdr->bh_caplen == bpf_hdr->bh_datalen);
 | 
							assert(bpf_hdr->bh_caplen == bpf_hdr->bh_datalen);
 | 
				
			||||||
 | 
					 | 
				
			||||||
		offset = bpf_hdr->bh_hdrlen + LLC_LEN + ETHER_HDR_LEN;
 | 
							offset = bpf_hdr->bh_hdrlen + LLC_LEN + ETHER_HDR_LEN;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* then we lose the BPF, LLC and ethernet headers */
 | 
							/* then we lose the BPF, LLC and ethernet headers */
 | 
				
			||||||
	stream_write(circuit->rcv_stream, readbuff + offset,
 | 
							stream_write(circuit->rcv_stream, buff_ptr + offset,
 | 
				
			||||||
			     bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN);
 | 
								     bpf_hdr->bh_caplen - LLC_LEN - ETHER_HDR_LEN);
 | 
				
			||||||
		stream_set_getp(circuit->rcv_stream, 0);
 | 
							stream_set_getp(circuit->rcv_stream, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	memcpy(ssnpa, readbuff + bpf_hdr->bh_hdrlen + ETH_ALEN, ETH_ALEN);
 | 
							memcpy(ssnpa, buff_ptr + bpf_hdr->bh_hdrlen + ETHER_ADDR_LEN,
 | 
				
			||||||
 | 
							ETHER_ADDR_LEN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							err = isis_handle_pdu(circuit, ssnpa);
 | 
				
			||||||
 | 
							stream_reset(circuit->rcv_stream);
 | 
				
			||||||
 | 
							buff_ptr += BPF_WORDALIGN(bpf_hdr->bh_hdrlen +
 | 
				
			||||||
 | 
											bpf_hdr->bh_datalen);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ioctl(circuit->fd, BIOCFLUSH, &one) < 0)
 | 
						if (ioctl(circuit->fd, BIOCFLUSH, &one) < 0)
 | 
				
			||||||
		zlog_warn("Flushing failed: %s", safe_strerror(errno));
 | 
							zlog_warn("Flushing failed: %s", safe_strerror(errno));
 | 
				
			||||||
 | 
				
			|||||||
@ -1336,7 +1336,7 @@ static int pdu_size(uint8_t pdu_type, uint8_t *size)
 | 
				
			|||||||
 * PDU Dispatcher
 | 
					 * PDU Dispatcher
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int isis_handle_pdu(struct isis_circuit *circuit, u_char *ssnpa)
 | 
					int isis_handle_pdu(struct isis_circuit *circuit, u_char *ssnpa)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int retval = ISIS_OK;
 | 
						int retval = ISIS_OK;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1459,8 +1459,10 @@ int isis_receive(struct thread *thread)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	retval = circuit->rx(circuit, ssnpa);
 | 
						retval = circuit->rx(circuit, ssnpa);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if ISIS_METHOD != ISIS_METHOD_BPF
 | 
				
			||||||
	if (retval == ISIS_OK)
 | 
						if (retval == ISIS_OK)
 | 
				
			||||||
		retval = isis_handle_pdu(circuit, ssnpa);
 | 
							retval = isis_handle_pdu(circuit, ssnpa);
 | 
				
			||||||
 | 
					#endif //ISIS_METHOD != ISIS_METHOD_BPF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * prepare for next packet.
 | 
						 * prepare for next packet.
 | 
				
			||||||
 | 
				
			|||||||
@ -215,5 +215,5 @@ int send_l2_psnp(struct thread *thread);
 | 
				
			|||||||
int send_lsp(struct thread *thread);
 | 
					int send_lsp(struct thread *thread);
 | 
				
			||||||
void fill_fixed_hdr(uint8_t pdu_type, struct stream *stream);
 | 
					void fill_fixed_hdr(uint8_t pdu_type, struct stream *stream);
 | 
				
			||||||
int send_hello(struct isis_circuit *circuit, int level);
 | 
					int send_hello(struct isis_circuit *circuit, int level);
 | 
				
			||||||
 | 
					int isis_handle_pdu(struct isis_circuit *circuit, u_char *ssnpa);
 | 
				
			||||||
#endif /* _ZEBRA_ISIS_PDU_H */
 | 
					#endif /* _ZEBRA_ISIS_PDU_H */
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user