View | Details | Raw Unified | Return to bug 72402
Collapse All | Expand All

(-)pppoe.c (-9 / +73 lines)
Lines 18-23 Link Here
18
#include <netgraph/ng_tee.h>
18
#include <netgraph/ng_tee.h>
19
#include <netgraph.h>
19
#include <netgraph.h>
20
20
21
#include <sys/param.h>
22
#include <sys/linker.h>
23
21
/*
24
/*
22
 * DEFINITIONS
25
 * DEFINITIONS
23
 */
26
 */
Lines 180-186 Link Here
180
	pe->incoming = 0;
183
	pe->incoming = 0;
181
	snprintf(pe->path, sizeof(pe->path), "undefined:");
184
	snprintf(pe->path, sizeof(pe->path), "undefined:");
182
	snprintf(pe->hook, sizeof(pe->hook), "undefined");
185
	snprintf(pe->hook, sizeof(pe->hook), "undefined");
183
	snprintf(pe->session, sizeof(pe->session), "undefined");
186
	snprintf(pe->session, sizeof(pe->session), "*");
184
	for (i=0; i<6; i++)
187
	for (i=0; i<6; i++)
185
	    pe->peeraddr[i]=0x00;
188
	    pe->peeraddr[i]=0x00;
186
	pe->link = lnk;
189
	pe->link = lnk;
Lines 467-481 Link Here
467
}
470
}
468
471
469
static int 
472
static int 
470
CreatePppoeNode(const char *path, const char *hook) {
473
CreatePppoeNode(const char *path, const char *hook)
471
474
{
472
	u_char rbuf[2048];
475
	u_char rbuf[2048];
473
	struct ng_mesg *resp;
476
	struct ng_mesg *resp;
477
	const struct typelist *tlist;
474
	const struct hooklist *hlist;
478
	const struct hooklist *hlist;
475
	const struct nodeinfo *ninfo;
479
	const struct nodeinfo *ninfo;
476
	const struct linkinfo *nlink;
480
	const struct linkinfo *nlink;
477
	int f;
481
	int f;
478
	int csock;
482
	int csock;
483
	int kldload_tried = 0;
484
	static int check_ng_ether = 1;
479
485
480
	/* Make sure interface is up */
486
	/* Make sure interface is up */
481
	char iface[IFNAMSIZ + 1];
487
	char iface[IFNAMSIZ + 1];
Lines 497-502 Link Here
497
	}
503
	}
498
	(void)fcntl(csock, F_SETFD, 1);
504
	(void)fcntl(csock, F_SETFD, 1);
499
505
506
	/* Check if NG_ETHER_NODE_TYPE is available */
507
	for (kldload_tried=0; check_ng_ether;) {
508
		/* Ask for a list of available node types */
509
		if (NgSendMsg(csock, "", NGM_GENERIC_COOKIE, NGM_LISTTYPES,				NULL, 0) < 0) {
510
			Log(LG_ERR, ("[%s] Cannot send a netgraph message: %s",
511
				lnk->name, strerror(errno)));
512
			close(csock);
513
			return(0);
514
		}
515
516
		/* Get response */
517
		resp = (struct ng_mesg *)rbuf;
518
		if (NgRecvMsg(csock, resp, sizeof rbuf, NULL) <= 0) {
519
			Log(LG_ERR, ("[%s] Cannot get netgraph response: %s",
520
				lnk->name, strerror(errno)));
521
			close(csock);
522
			return(0);
523
		}
524
525
		/* Look for NG_ETHER_NODE_TYPE */
526
		tlist = (const struct typelist*) resp->data;
527
		for (f=0; f<tlist->numtypes; ++f)
528
			if (!strncmp(tlist->typeinfo[f].type_name,
529
			    NG_ETHER_NODE_TYPE, sizeof NG_ETHER_NODE_TYPE - 1))
530
				break;
531
532
		/* If found do not run this check anymore */
533
		if (f < tlist->numtypes) {
534
			check_ng_ether=0;
535
			break;
536
		}
537
538
		/* If not found try to load ng_ether and repeat the check */
539
		if (kldload_tried) {
540
			Log(LG_ERR, ("[%s] Still no NG_ETHER_NODE_TYPE after kldload(\"ng_ether\")", lnk->name));
541
			close(csock);
542
			return(0);
543
		}
544
545
		if (kldload("ng_ether") < 0) {
546
			if (errno == EEXIST)
547
				Log(LG_ERR, ("[%s] ng_ether already loaded but NG_ETHER_NODE_TYPE is not available", lnk->name));
548
			else
549
				Log(LG_ERR, ("[%s] Cannot load ng_ether: %s", lnk->name, strerror(errno)));
550
			close(csock);
551
			return(0);
552
		}
553
		kldload_tried = 1;
554
	}
555
500
	/*
556
	/*
501
	* Ask for a list of hooks attached to the "ether" node.  This node should
557
	* Ask for a list of hooks attached to the "ether" node.  This node should
502
	* magically exist as a way of hooking stuff onto an ethernet device
558
	* magically exist as a way of hooking stuff onto an ethernet device
Lines 811-819 Link Here
811
867
812
  /* Examine all PPPoE links */
868
  /* Examine all PPPoE links */
813
  for (k = 0; k < gNumLinks; k++) {
869
  for (k = 0; k < gNumLinks; k++) {
814
    if (gLinks[k] && gLinks[k]->phys->type == &gPppoePhysType 
870
    if (gLinks[k] && gLinks[k]->phys->type == &gPppoePhysType) {
815
      && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->path,"undefined:") 
871
816
      && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->session,"undefined")) {
872
	if (!strcmp(((PppoeInfo)(gLinks[k]->phys->info))->path, "undefined:")) {
873
		Log(LG_PHYS, ("[%s] Skipping link %s with undefined interface",
874
			lnk->name, gLinks[k]->name));
875
		continue;
876
	}
817
877
818
        PppoeInfo	const p = (PppoeInfo)gLinks[k]->phys->info;
878
        PppoeInfo	const p = (PppoeInfo)gLinks[k]->phys->info;
819
879
Lines 854-862 Link Here
854
914
855
  /* Examine all PPPoE links */
915
  /* Examine all PPPoE links */
856
  for (k = 0; k < gNumLinks; k++) {
916
  for (k = 0; k < gNumLinks; k++) {
857
    if (gLinks[k] && gLinks[k]->phys->type == &gPppoePhysType 
917
    if (gLinks[k] && gLinks[k]->phys->type == &gPppoePhysType ) {
858
      && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->path,"undefined:") 
918
859
      && strcmp(((PppoeInfo)(gLinks[k]->phys->info))->session,"undefined")) {
919
	if (!strcmp(((PppoeInfo)(gLinks[k]->phys->info))->path, "undefined:")) {
920
		Log(LG_PHYS, ("[%s] Skipping link %s with undefined interface",
921
			lnk->name, gLinks[k]->name));
922
		continue;
923
	}
860
924
861
        PppoeInfo	const p = (PppoeInfo)gLinks[k]->phys->info;
925
        PppoeInfo	const p = (PppoeInfo)gLinks[k]->phys->info;
862
926

Return to bug 72402